Skip to main content

DevcontextRequest

Struct DevcontextRequest 

Source
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: bool

Every blocking rule of the layer, not only the ones the work reaches

Trait Implementations§

Source§

impl Args for DevcontextRequest

Source§

fn group_id() -> Option<Id>

Report the [ArgGroup::id][crate::ArgGroup::id] for this set of arguments
Source§

fn augment_args<'b>(__clap_app: Command) -> Command

Append to [Command] so it can instantiate Self via [FromArgMatches::from_arg_matches_mut] Read more
Source§

fn augment_args_for_update<'b>(__clap_app: Command) -> Command

Append to [Command] so it can instantiate self via [FromArgMatches::update_from_arg_matches_mut] Read more
Source§

impl Clone for DevcontextRequest

Source§

fn clone(&self) -> DevcontextRequest

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DevcontextRequest

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FromArgMatches for DevcontextRequest

Source§

fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>

Instantiate Self from [ArgMatches], parsing the arguments as needed. Read more
Source§

fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>

Instantiate Self from [ArgMatches], parsing the arguments as needed. Read more
Source§

fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.
Source§

fn update_from_arg_matches_mut( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more