pub struct DevcontextRequest {
pub issue: Option<String>,
pub milestone: Option<String>,
pub intent: Option<String>,
pub paths: Vec<String>,
pub uris: Vec<String>,
pub budget_tokens: Option<u64>,
pub max_depth: Option<usize>,
pub floor: Option<f64>,
pub all_blocking_rules: bool,
}Expand description
What to compile a context about; every flag is optional, and naming nothing is a legitimate request.
This is the command-line half of
CompileInput, field for field, which is why the
repeated flags are --path and --uri singular while the fields behind them are
plural: a person adds one path at a time, and the request holds the set. A request that
names nothing still compiles — to the governance the layer applies to everything, plus
what the last session left.
use clap::Parser;
use majordomus_cli::cli::{Cli, Command, DevcontextCommand, DevcontextRequest};
// one type behind both subcommands, which is why `explain` can judge an identifier
// under exactly the request `compile` would have used
let request_of = |argv: &[&str]| -> DevcontextRequest {
let cli = Cli::try_parse_from(argv).unwrap();
let Command::Devcontext(args) = cli.command else { panic!("devcontext") };
match args.command {
DevcontextCommand::Compile(request) => request,
DevcontextCommand::Explain { request, .. } => request,
DevcontextCommand::Policy => panic!("`policy` takes no request"),
}
};
let compiling = request_of(&[
"majordomus", "devcontext", "compile",
"--path", "apps/majordomus-cli/src", "--path", "lib",
"--uri", "majordomus://adr/0052",
"--floor", "0.4", "--all-blocking-rules",
]);
// repeated singular flags accumulate into the set the compiler seeds from
assert_eq!(compiling.paths, ["apps/majordomus-cli/src", "lib"]);
assert_eq!(compiling.uris, ["majordomus://adr/0052"]);
assert_eq!(compiling.floor, Some(0.4));
assert!(compiling.all_blocking_rules);
// the same flags reach `explain`, after its positional identifier
let explaining = request_of(&[
"majordomus", "devcontext", "explain", "majordomus://adr/0052", "--max-depth", "1",
]);
assert_eq!(explaining.max_depth, Some(1));
// and nothing is required: the smallest true context there is
let silent = request_of(&["majordomus", "devcontext", "compile"]);
assert!(silent.issue.is_none() && silent.paths.is_empty());
assert!(!silent.all_blocking_rules && silent.floor.is_none());Fields§
§issue: Option<String>An issue id (I0301) or its canonical identifier
milestone: Option<String>A milestone id or slug, or its canonical identifier
intent: Option<String>What the session is trying to do, in words; the only input the compiler infers from
paths: Vec<String>A repository-relative path the work touches; repeat for each
uris: Vec<String>A canonical identifier to seed with directly; repeat for each
budget_tokens: Option<u64>The ceiling in estimated tokens
max_depth: Option<usize>How far from a seed the walk goes
floor: Option<f64>Relevance below which an entry is reported rather than given, between 0 and 1
all_blocking_rules: boolEvery blocking rule of the layer, not only the ones the work reaches
Trait Implementations§
Source§impl Args for DevcontextRequest
impl Args for DevcontextRequest
Source§fn group_id() -> Option<Id>
fn group_id() -> Option<Id>
ArgGroup::id][crate::ArgGroup::id] for this set of argumentsSource§fn augment_args<'b>(__clap_app: Command) -> Command
fn augment_args<'b>(__clap_app: Command) -> Command
Source§fn augment_args_for_update<'b>(__clap_app: Command) -> Command
fn augment_args_for_update<'b>(__clap_app: Command) -> Command
Command] so it can instantiate self via
[FromArgMatches::update_from_arg_matches_mut] Read moreSource§impl Clone for DevcontextRequest
impl Clone for DevcontextRequest
Source§fn clone(&self) -> DevcontextRequest
fn clone(&self) -> DevcontextRequest
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DevcontextRequest
impl Debug for DevcontextRequest
Source§impl FromArgMatches for DevcontextRequest
impl FromArgMatches for DevcontextRequest
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(
&mut self,
__clap_arg_matches: &mut ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches_mut( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>
ArgMatches to self.