Skip to main content

Args

Struct Args 

Source
pub struct Args {
    pub manifest_path: Option<PathBuf>,
    pub packages: Vec<String>,
    pub header_file: Option<PathBuf>,
    pub format: OutputFormat,
    pub offence_threshold: Option<usize>,
    pub list_rules: bool,
    pub rules: Vec<String>,
    pub fix: bool,
    pub baseline: Option<PathBuf>,
    pub write_baseline: bool,
    pub excludes: Vec<String>,
    pub skipped_rules: Vec<String>,
}

Fields§

§manifest_path: Option<PathBuf>

Workspace or package manifest to analyse. Defaults to the Cargo.toml in the current directory, which is what makes a bare cargo stern4rust work from inside the thing being judged.

§packages: Vec<String>

Restrict the run to these packages; repeatable. Omit to take the manifest’s own package, or every member if it is a workspace root. Naming a package that the manifest does not scan is an error rather than an empty run, because a typo in a gate script otherwise reads as a pass.

§header_file: Option<PathBuf>

File holding the header every .rs file must open with. It is data rather than a built-in constant because it is never the same twice: MIT here, Apache 2.0 in a sibling repository, and a different year again next year.

§format: OutputFormat

How to report. The table is for a person; json is the same run as a document, for a gate script or an agent that would otherwise have to guess where one column of the table ends and the next begins.

§offence_threshold: Option<usize>

How many offences the report prints. A first run against a large codebase can find a thousand, and a thousand rows is a wall rather than a report. The cap is on what is shown and never on what is counted: the summary, the omitted count and the exit code all see every offence. Use 0 for no limit. Option rather than a defaulted value so that “not passed” is distinguishable from “passed the default”: without that, a stern4rust.toml could never set the threshold, because every run would look like the reader had asked for 100 on the command line.

§list_rules: bool

List every rule with a line saying what it wants, a scrap of source that breaks it and the same scrap put right, then exit without scanning. Answers the question a first run raises – what does this rule actually want – without needing a codebase to ask it against.

§rules: Vec<String>

Apply only these rules; repeatable. Omit to apply every rule. Naming one makes the selection a whitelist, which is what lets a codebase facing hundreds of offences gate on one rule today and the rest as it goes.

§fix: bool

Repair what can be repaired mechanically, then report what is left. Only test-file-structure offences are fixable today: item order, section order and blank lines. Everything else is reported unchanged, and the report says how many offences were fixed and how many were not.

§baseline: Option<PathBuf>

Offences recorded here are not reported and do not fail the run. What lets a codebase with hundreds of existing offences enforce every rule against new code without first fixing the old. The count of suppressed offences is always in the summary, never hidden.

§write_baseline: bool

Record the current offences as the baseline and exit clean, instead of judging against one. Writes to –baseline, or to stern4rust-baseline.json beside the manifest.

§excludes: Vec<String>

Keep these paths out of the run; repeatable, matched as a glob against the package-relative path. For a tree the repository cannot move – vendored source, generated output. Every pattern is named in the report with how many files it removed, including zero, so an exclusion is something the reader can see rather than a silence.

§skipped_rules: Vec<String>

Do not apply these rules; repeatable. Subtracted from whatever –rule selected, so skipping wins over selecting.

Implementations§

Source§

impl Args

Source

pub fn without_cargo_subcommand<I>(args: I) -> Vec<String>
where I: IntoIterator<Item = String>,

Cargo invokes cargo stern4rust as cargo-stern4rust stern4rust ..., so the subcommand name arrives as an extra leading argument that clap would otherwise reject. Running the binary directly does not repeat it, which is why the strip is conditional rather than unconditional.

Trait Implementations§

Source§

impl Args for Args

Source§

fn group_id() -> Option<Id>

Report the 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 Args

Source§

fn clone(&self) -> Args

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 CommandFactory for Args

Source§

fn command<'b>() -> Command

Build a Command that can instantiate Self. Read more
Source§

fn command_for_update<'b>() -> Command

Build a Command that can update self. Read more
Source§

impl Debug for Args

Source§

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

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

impl FromArgMatches for Args

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.
Source§

impl Parser for Args

Source§

fn parse() -> Self

Parse from std::env::args_os(), exit on error.
Source§

fn try_parse() -> Result<Self, Error>

Parse from std::env::args_os(), return Err on error.
Source§

fn parse_from<I, T>(itr: I) -> Self
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Parse from iterator, exit on error.
Source§

fn try_parse_from<I, T>(itr: I) -> Result<Self, Error>
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Parse from iterator, return Err on error.
Source§

fn update_from<I, T>(&mut self, itr: I)
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Update from iterator, exit on error. Read more
Source§

fn try_update_from<I, T>(&mut self, itr: I) -> Result<(), Error>
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Update from iterator, return Err on error.

Auto Trait Implementations§

§

impl Freeze for Args

§

impl RefUnwindSafe for Args

§

impl Send for Args

§

impl Sync for Args

§

impl Unpin for Args

§

impl UnsafeUnpin for Args

§

impl UnwindSafe for Args

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
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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

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.