pub mod add;
pub mod admin;
#[cfg(not(feature = "lt2016_1"))]
pub mod aliases;
pub mod annotate;
pub mod archive;
pub mod attribute;
pub mod changes;
pub mod describe;
pub mod edit;
pub mod filelog;
pub mod print;
pub mod sync;
pub mod r#where;
pub use add::Add;
pub use admin::AdminEntry;
#[cfg(not(feature = "lt2016_1"))]
pub use aliases::Aliases;
pub use annotate::Annotate;
pub use archive::Archive;
pub use attribute::Attribute;
pub use changes::Changes;
pub use describe::Describe;
pub use edit::Edit;
pub use filelog::FileLog;
pub use print::Print;
pub use sync::Sync;
pub use r#where::Where;
use std::{ffi::OsStr, process::Command};
use crate::global::GlobalOpts;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum LongOutput {
Default,
Truncated,
}
impl LongOutput {
pub fn as_str(&self) -> &'static str {
match self {
LongOutput::Default => "-l",
LongOutput::Truncated => "-L",
}
}
}
#[derive(Debug, Clone, Copy, Default)]
pub struct Unselected;
impl ExclusiveOption for Unselected {
fn inject_args(&self, _: &mut Command) {}
}
pub trait ExclusiveOption {
#[allow(unused_variables)]
fn inject_args(&self, command: &mut Command) {}
}
pub trait SubCommand {
fn name(&self) -> &str;
fn inject_local_args(&self, command: &mut Command);
fn global_opts(&self) -> Option<&GlobalOpts> {
None
}
fn inject_args(&self, command: &mut Command) {
if let Some(global_opts) = self.global_opts() {
global_opts.setup_args(command);
};
self.inject_local_args(command.arg(self.name()));
}
fn setup_command<S: AsRef<OsStr>>(&self, bin: S) -> Command {
let mut cmd = Command::new(bin);
self.inject_args(&mut cmd);
cmd
}
}
#[cfg(test)]
pub(crate) fn args_of(command: &Command) -> Vec<String> {
command
.get_args()
.map(|arg| arg.to_string_lossy().into_owned())
.collect()
}