From 094f84d2c320bc7320674ba23c715f9fbe634862 Mon Sep 17 00:00:00 2001 From: diogo464 Date: Fri, 9 Jul 2021 05:23:11 -0400 Subject: Changed documentation/help text of subcommands. Change the documentation/help text of subcommmands and added colored output to the help text. --- dotup_cli/src/commands/init.rs | 7 +++++-- dotup_cli/src/commands/install.rs | 10 +++++++--- dotup_cli/src/commands/link.rs | 10 +++++++++- dotup_cli/src/commands/uninstall.rs | 9 +++++++-- dotup_cli/src/commands/unlink.rs | 10 ++++++++-- dotup_cli/src/main.rs | 5 ++++- 6 files changed, 40 insertions(+), 11 deletions(-) (limited to 'dotup_cli/src') diff --git a/dotup_cli/src/commands/init.rs b/dotup_cli/src/commands/init.rs index bfec6ca..8765dbf 100644 --- a/dotup_cli/src/commands/init.rs +++ b/dotup_cli/src/commands/init.rs @@ -1,8 +1,11 @@ -use clap::Clap; - use super::prelude::*; +/// Creates an empty depot file if one doesnt already exist. +/// +/// By default this will create the file in the current directory +/// but the --depot flag can be used to change this path. #[derive(Clap)] +#[clap(setting = AppSettings::ColoredHelp)] pub struct Opts {} pub fn main(config: Config, opts: Opts) -> anyhow::Result<()> { diff --git a/dotup_cli/src/commands/install.rs b/dotup_cli/src/commands/install.rs index 72cabf3..16343c5 100644 --- a/dotup_cli/src/commands/install.rs +++ b/dotup_cli/src/commands/install.rs @@ -1,16 +1,20 @@ -use clap::Clap; use std::path::PathBuf; use super::prelude::*; +/// Install links. (Creates symlinks). +/// +/// Installing a link will create the necessary directories. +/// If a file or directory already exists at the location a link would be installed this command will fail. #[derive(Clap)] +#[clap(setting = AppSettings::ColoredHelp)] pub struct Opts { /// The location where links will be installed to. - /// Defaults to home directory. + /// Defaults to the home directory. #[clap(long)] install_base: Option, - /// The files/directories to install + /// The files/directories to install. #[clap(required = true, min_values = 1)] paths: Vec, } diff --git a/dotup_cli/src/commands/link.rs b/dotup_cli/src/commands/link.rs index 614c0ca..81c396b 100644 --- a/dotup_cli/src/commands/link.rs +++ b/dotup_cli/src/commands/link.rs @@ -1,4 +1,3 @@ -use clap::Clap; use std::{ fs::{DirEntry, Metadata}, path::{Path, PathBuf}, @@ -6,11 +5,20 @@ use std::{ use super::prelude::*; +/// Creates links +/// +/// If a link is created for a file that already had a link then the old link will be overwritten. +/// By default creating a link to a directory will recursively link all files under that +/// directory, to actually link a directory use the --directory flag. #[derive(Clap)] +#[clap(setting = AppSettings::ColoredHelp)] pub struct Opts { + /// Treats the paths as directories. This will create links to the actual directories instead + /// of recursively linking all files under them. #[clap(long)] directory: bool, + /// The paths to link. The last path is the destination. paths: Vec, } diff --git a/dotup_cli/src/commands/uninstall.rs b/dotup_cli/src/commands/uninstall.rs index dad55a5..44c33b2 100644 --- a/dotup_cli/src/commands/uninstall.rs +++ b/dotup_cli/src/commands/uninstall.rs @@ -1,16 +1,21 @@ -use clap::Clap; use std::path::PathBuf; use super::prelude::*; +/// Uninstalls links. (Removes symlinks). +/// +/// Uninstalling a link for a file that didnt have a link will do nothing. +/// Uninstalling a directory will recursively uninstall all files under it. +/// Symlinks are only deleted if they were pointing to the correct file. #[derive(Clap)] +#[clap(setting = AppSettings::ColoredHelp)] pub struct Opts { /// The location where links will be uninstalled from. /// Defaults to home directory. #[clap(long)] install_base: Option, - /// The files/directories to uninstall + /// The files/directories to uninstall. #[clap(required = true, min_values = 1)] paths: Vec, } diff --git a/dotup_cli/src/commands/unlink.rs b/dotup_cli/src/commands/unlink.rs index 7ebb19c..f33fe60 100644 --- a/dotup_cli/src/commands/unlink.rs +++ b/dotup_cli/src/commands/unlink.rs @@ -1,4 +1,3 @@ -use clap::Clap; use std::{ fs::{DirEntry, Metadata}, path::{Path, PathBuf}, @@ -6,12 +5,19 @@ use std::{ use super::prelude::*; +/// Unlinks files/directories. +/// +/// This will recursively remove links. If a path is a directory then it will remove all links +/// recursively. +/// The links are not uninstall by default, see the --uninstall parameter. #[derive(Clap)] +#[clap(setting = AppSettings::ColoredHelp)] pub struct Opts { - /// Specifies the install base if the links are also to be uninstalled. + /// Specify the install base if the links are also to be uninstalled. #[clap(long)] uninstall: Option, + /// The paths to unlink. #[clap(required = true, min_values = 1)] paths: Vec, } diff --git a/dotup_cli/src/main.rs b/dotup_cli/src/main.rs index 8830853..867afb4 100644 --- a/dotup_cli/src/main.rs +++ b/dotup_cli/src/main.rs @@ -7,6 +7,7 @@ pub use config::Config; pub mod prelude { pub use super::Config; + pub use clap::{AppSettings, Clap}; pub use dotup::{Archive, Depot, DepotConfig, Link, LinkCreateParams, LinkID}; } @@ -23,7 +24,6 @@ use prelude::*; const DEFAULT_DEPOT_NAME: &str = "depot.toml"; #[derive(Clap)] -#[clap(version = "0.1", author = "d464")] #[clap(setting = AppSettings::ColoredHelp)] struct Opts { /// Path to the depot file. @@ -37,8 +37,11 @@ struct Opts { /// A level of verbosity, and can be used multiple times /// /// Level 0 - Warnings (Default) + /// /// Level 1 - Info + /// /// Level 2 - Debug + /// /// Level 3 - Trace #[clap(short, long, parse(from_occurrences))] verbose: i32, -- cgit