pub enum DevcontextCommand {
Compile(DevcontextRequest),
Explain {
uri: String,
request: DevcontextRequest,
},
Policy,
}Expand description
What to ask of the context compiler: compile an answer, ask why one identifier is or is not in it, or read the rules the compiler decides by.
Explain takes the identifier positionally and then the same request flags as
Compile, because the question it answers is about a compiled answer — “why is this
not in it” is only meaningful against the request that left it out. Policy takes
nothing: it is the compiler’s own table, not a question about a repository.
use clap::Parser;
use majordomus_cli::cli::{Cli, Command, DevcontextCommand};
let parse = |argv: &[&str]| {
let cli = Cli::try_parse_from(argv).unwrap();
let Command::Devcontext(args) = cli.command else { panic!("devcontext") };
args.command
};
// the identifier is positional and the request flags follow it, so the budget the
// judgement is made under is part of the question
let explain = parse(&[
"majordomus", "devcontext", "explain", "majordomus://rule/x@1", "--max-depth", "1",
]);
let DevcontextCommand::Explain { uri, request } = explain else { panic!("explain") };
assert_eq!(uri, "majordomus://rule/x@1");
assert_eq!(request.max_depth, Some(1));
// `policy` is about the compiler and not about a request, so it accepts no request flag
assert!(matches!(
parse(&["majordomus", "devcontext", "policy"]),
DevcontextCommand::Policy
));
assert!(
Cli::try_parse_from(["majordomus", "devcontext", "policy", "--intent", "x"]).is_err(),
"the rules do not depend on what is being asked about"
);Variants§
Compile(DevcontextRequest)
Compile the context for a piece of work: every selected object with its provenance, the reason and the confidence, everything left out with the reason, what was deduplicated, and the per-tier budget; exit 10 when what may not be dropped already exceeds the budget
Explain
Why one canonical identifier is or is not in the context a request compiles to
Fields
request: DevcontextRequestThe request to judge it under.
Policy
The compiler’s own rules: the tiers, every edge of the composed graph and what is done with it, the selectors, the defaults
Trait Implementations§
Source§impl Debug for DevcontextCommand
impl Debug for DevcontextCommand
Source§impl FromArgMatches for DevcontextCommand
impl FromArgMatches for DevcontextCommand
Source§fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
Source§fn from_arg_matches_mut(
__clap_arg_matches: &mut ArgMatches,
) -> Result<Self, Error>
fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>
Source§fn update_from_arg_matches(
&mut self,
__clap_arg_matches: &ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>
ArgMatches to self.Source§fn update_from_arg_matches_mut<'b>(
&mut self,
__clap_arg_matches: &mut ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches_mut<'b>( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>
ArgMatches to self.Source§impl Subcommand for DevcontextCommand
impl Subcommand for DevcontextCommand
Source§fn augment_subcommands<'b>(__clap_app: Command) -> Command
fn augment_subcommands<'b>(__clap_app: Command) -> Command
Source§fn augment_subcommands_for_update<'b>(__clap_app: Command) -> Command
fn augment_subcommands_for_update<'b>(__clap_app: Command) -> Command
Command] so it can instantiate self via
[FromArgMatches::update_from_arg_matches_mut] Read moreSource§fn has_subcommand(__clap_name: &str) -> bool
fn has_subcommand(__clap_name: &str) -> bool
Self can parse a specific subcommand