Skip to content

Commit

Permalink
Prefix meta calls with commands mod
Browse files Browse the repository at this point in the history
  • Loading branch information
jpikl committed May 10, 2024
1 parent 25f64ad commit c1bf991
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::colors::BOLD;
use crate::colors::RESET;
use crate::commands::METAS;
use crate::commands;
use crate::env;
use clap::command;
use clap::crate_description;
Expand All @@ -18,7 +18,7 @@ pub fn build() -> Command {
.after_help(get_after_help(None))
.subcommand_required(true);

for meta in METAS {
for meta in commands::METAS {
let command = meta.build().after_help(get_after_help(Some(meta.name)));
app = app.subcommand(command);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use rew::app;
use rew::commands::get_meta;
use rew::commands;
use rew::error::Reporter;
use std::io;
use std::process::ExitCode;
Expand All @@ -22,7 +22,7 @@ fn main() -> ExitCode {
};

let (cmd_name, cmd_matches) = matches.subcommand().expect("command not matched");
let cmd = get_meta(cmd_name).expect("command not found");
let cmd = commands::get_meta(cmd_name).expect("command not found");

match cmd.run(cmd_matches) {
Ok(()) => ExitCode::from(0),
Expand Down
6 changes: 3 additions & 3 deletions src/process.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::command::Group;
use crate::command::Meta;
use crate::commands::get_meta;
use crate::commands;
use crate::env::Env;
use crate::spawn::ContextItem;
use crate::spawn::SpawnWithContext;
Expand Down Expand Up @@ -43,14 +43,14 @@ impl Command {

if name == crate_name!() {
if let Some((name, args)) = args.split_first() {
if let Some(meta) = get_meta(name) {
if let Some(meta) = commands::get_meta(name) {
return Self::internal(meta, args);
}
}
return Self::unknown_internal(args);
}

if let Some(meta) = get_meta(name) {
if let Some(meta) = commands::get_meta(name) {
return Self::internal(meta, args);
}

Expand Down
4 changes: 2 additions & 2 deletions xtask/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use clap::Arg;
use clap::Command;
use rew::command::Group;
use rew::command::Meta;
use rew::commands::get_meta;
use rew::commands;
use rew::examples::Example;
use std::borrow::Cow;
use std::iter::Peekable;
Expand All @@ -32,7 +32,7 @@ impl<'a> Adapter<'a> {

fn meta(&self) -> Option<&'static Meta> {
if self.parents.len() == 1 {
get_meta(self.name()) // Only the main commands have metadata
commands::get_meta(self.name()) // Only the main commands have metadata
} else {
None
}
Expand Down

0 comments on commit c1bf991

Please sign in to comment.