mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-23 00:00:02 +03:00
remove redundant "cmd_" prefix from functions in "commands"
It is more idiomatic to use `commands::mount` than `commands::cmd_mount`. No functionality changes intended by this patch. Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
578f32a96e
commit
2b8a0f0caf
@ -4,10 +4,6 @@ mod key;
|
|||||||
|
|
||||||
use std::ffi::{c_char, CString};
|
use std::ffi::{c_char, CString};
|
||||||
|
|
||||||
use commands::cmd_completions::cmd_completions;
|
|
||||||
use commands::cmd_list::cmd_list;
|
|
||||||
use commands::cmd_mount::cmd_mount;
|
|
||||||
use commands::cmd_subvolume::cmd_subvolumes;
|
|
||||||
use commands::logger::SimpleLogger;
|
use commands::logger::SimpleLogger;
|
||||||
use bch_bindgen::c;
|
use bch_bindgen::c;
|
||||||
|
|
||||||
@ -110,10 +106,10 @@ fn main() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let ret = match cmd {
|
let ret = match cmd {
|
||||||
"completions" => cmd_completions(args[1..].to_vec()),
|
"completions" => commands::completions(args[1..].to_vec()),
|
||||||
"list" => cmd_list(args[1..].to_vec()),
|
"list" => commands::list(args[1..].to_vec()),
|
||||||
"mount" => cmd_mount(args, symlink_cmd),
|
"mount" => commands::mount(args, symlink_cmd),
|
||||||
"subvolume" => cmd_subvolumes(args[1..].to_vec()),
|
"subvolume" => commands::subvolume(args[1..].to_vec()),
|
||||||
_ => handle_c_command(args, symlink_cmd),
|
_ => handle_c_command(args, symlink_cmd),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ fn print_completions<G: Generator>(gen: G, cmd: &mut Command) {
|
|||||||
generate(gen, cmd, cmd.get_name().to_string(), &mut io::stdout());
|
generate(gen, cmd, cmd.get_name().to_string(), &mut io::stdout());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cmd_completions(argv: Vec<String>) -> i32 {
|
pub fn completions(argv: Vec<String>) -> i32 {
|
||||||
let cli = Cli::parse_from(argv);
|
let cli = Cli::parse_from(argv);
|
||||||
print_completions(cli.shell, &mut super::Cli::command());
|
print_completions(cli.shell, &mut super::Cli::command());
|
||||||
0
|
0
|
@ -157,7 +157,7 @@ fn cmd_list_inner(opt: Cli) -> anyhow::Result<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cmd_list(argv: Vec<String>) -> i32 {
|
pub fn list(argv: Vec<String>) -> i32 {
|
||||||
let opt = Cli::parse_from(argv);
|
let opt = Cli::parse_from(argv);
|
||||||
colored::control::set_override(opt.colorize);
|
colored::control::set_override(opt.colorize);
|
||||||
if let Err(e) = cmd_list_inner(opt) {
|
if let Err(e) = cmd_list_inner(opt) {
|
@ -1,10 +1,15 @@
|
|||||||
use clap::Subcommand;
|
use clap::Subcommand;
|
||||||
|
|
||||||
pub mod logger;
|
pub mod logger;
|
||||||
pub mod cmd_mount;
|
pub mod mount;
|
||||||
pub mod cmd_list;
|
pub mod list;
|
||||||
pub mod cmd_completions;
|
pub mod completions;
|
||||||
pub mod cmd_subvolume;
|
pub mod subvolume;
|
||||||
|
|
||||||
|
pub use mount::mount;
|
||||||
|
pub use list::list;
|
||||||
|
pub use completions::completions;
|
||||||
|
pub use subvolume::subvolume;
|
||||||
|
|
||||||
#[derive(clap::Parser, Debug)]
|
#[derive(clap::Parser, Debug)]
|
||||||
#[command(name = "bcachefs")]
|
#[command(name = "bcachefs")]
|
||||||
@ -15,11 +20,11 @@ pub struct Cli {
|
|||||||
|
|
||||||
#[derive(Subcommand, Debug)]
|
#[derive(Subcommand, Debug)]
|
||||||
enum Subcommands {
|
enum Subcommands {
|
||||||
List(cmd_list::Cli),
|
List(list::Cli),
|
||||||
Mount(cmd_mount::Cli),
|
Mount(mount::Cli),
|
||||||
Completions(cmd_completions::Cli),
|
Completions(completions::Cli),
|
||||||
#[command(visible_aliases = ["subvol"])]
|
#[command(visible_aliases = ["subvol"])]
|
||||||
Subvolume(cmd_subvolume::Cli),
|
Subvolume(subvolume::Cli),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
|
@ -86,7 +86,7 @@ fn parse_mount_options(options: impl AsRef<str>) -> (Option<String>, libc::c_ulo
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mount(
|
fn do_mount(
|
||||||
device: String,
|
device: String,
|
||||||
target: impl AsRef<std::path::Path>,
|
target: impl AsRef<std::path::Path>,
|
||||||
options: impl AsRef<str>,
|
options: impl AsRef<str>,
|
||||||
@ -276,7 +276,7 @@ fn cmd_mount_inner(opt: Cli) -> anyhow::Result<()> {
|
|||||||
&opt.options
|
&opt.options
|
||||||
);
|
);
|
||||||
|
|
||||||
mount(devices, mountpoint, &opt.options)?;
|
do_mount(devices, mountpoint, &opt.options)?;
|
||||||
} else {
|
} else {
|
||||||
info!(
|
info!(
|
||||||
"would mount with params: device: {}, options: {}",
|
"would mount with params: device: {}, options: {}",
|
||||||
@ -288,7 +288,7 @@ fn cmd_mount_inner(opt: Cli) -> anyhow::Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cmd_mount(mut argv: Vec<String>, symlink_cmd: Option<&str>) -> i32 {
|
pub fn mount(mut argv: Vec<String>, symlink_cmd: Option<&str>) -> i32 {
|
||||||
// If the bcachefs tool is being called as "bcachefs mount dev ..." (as opposed to via a
|
// If the bcachefs tool is being called as "bcachefs mount dev ..." (as opposed to via a
|
||||||
// symlink like "/usr/sbin/mount.bcachefs dev ...", then we need to pop the 0th argument
|
// symlink like "/usr/sbin/mount.bcachefs dev ...", then we need to pop the 0th argument
|
||||||
// ("bcachefs") since the CLI parser here expects the device at position 1.
|
// ("bcachefs") since the CLI parser here expects the device at position 1.
|
@ -36,7 +36,7 @@ enum Subcommands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cmd_subvolumes(argv: Vec<String>) -> i32 {
|
pub fn subvolume(argv: Vec<String>) -> i32 {
|
||||||
let args = Cli::parse_from(argv);
|
let args = Cli::parse_from(argv);
|
||||||
|
|
||||||
match args.subcommands {
|
match args.subcommands {
|
Loading…
Reference in New Issue
Block a user