diff options
| author | diogo464 <[email protected]> | 2021-07-09 05:23:11 -0400 |
|---|---|---|
| committer | diogo464 <[email protected]> | 2021-07-09 05:23:11 -0400 |
| commit | 094f84d2c320bc7320674ba23c715f9fbe634862 (patch) | |
| tree | bf33ad3298d38639653267a87f235ee79847ae53 | |
| parent | 56c87da0183590a39a938a171c5cb80a3e702edd (diff) | |
Changed documentation/help text of subcommands.
Change the documentation/help text of subcommmands and added colored
output to the help text.
| -rw-r--r-- | dotup_cli/src/commands/init.rs | 7 | ||||
| -rw-r--r-- | dotup_cli/src/commands/install.rs | 10 | ||||
| -rw-r--r-- | dotup_cli/src/commands/link.rs | 10 | ||||
| -rw-r--r-- | dotup_cli/src/commands/uninstall.rs | 9 | ||||
| -rw-r--r-- | dotup_cli/src/commands/unlink.rs | 10 | ||||
| -rw-r--r-- | dotup_cli/src/main.rs | 5 |
6 files changed, 40 insertions, 11 deletions
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 @@ | |||
| 1 | use clap::Clap; | ||
| 2 | |||
| 3 | use super::prelude::*; | 1 | use super::prelude::*; |
| 4 | 2 | ||
| 3 | /// Creates an empty depot file if one doesnt already exist. | ||
| 4 | /// | ||
| 5 | /// By default this will create the file in the current directory | ||
| 6 | /// but the --depot flag can be used to change this path. | ||
| 5 | #[derive(Clap)] | 7 | #[derive(Clap)] |
| 8 | #[clap(setting = AppSettings::ColoredHelp)] | ||
| 6 | pub struct Opts {} | 9 | pub struct Opts {} |
| 7 | 10 | ||
| 8 | pub fn main(config: Config, opts: Opts) -> anyhow::Result<()> { | 11 | 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 @@ | |||
| 1 | use clap::Clap; | ||
| 2 | use std::path::PathBuf; | 1 | use std::path::PathBuf; |
| 3 | 2 | ||
| 4 | use super::prelude::*; | 3 | use super::prelude::*; |
| 5 | 4 | ||
| 5 | /// Install links. (Creates symlinks). | ||
| 6 | /// | ||
| 7 | /// Installing a link will create the necessary directories. | ||
| 8 | /// If a file or directory already exists at the location a link would be installed this command will fail. | ||
| 6 | #[derive(Clap)] | 9 | #[derive(Clap)] |
| 10 | #[clap(setting = AppSettings::ColoredHelp)] | ||
| 7 | pub struct Opts { | 11 | pub struct Opts { |
| 8 | /// The location where links will be installed to. | 12 | /// The location where links will be installed to. |
| 9 | /// Defaults to home directory. | 13 | /// Defaults to the home directory. |
| 10 | #[clap(long)] | 14 | #[clap(long)] |
| 11 | install_base: Option<PathBuf>, | 15 | install_base: Option<PathBuf>, |
| 12 | 16 | ||
| 13 | /// The files/directories to install | 17 | /// The files/directories to install. |
| 14 | #[clap(required = true, min_values = 1)] | 18 | #[clap(required = true, min_values = 1)] |
| 15 | paths: Vec<PathBuf>, | 19 | paths: Vec<PathBuf>, |
| 16 | } | 20 | } |
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 @@ | |||
| 1 | use clap::Clap; | ||
| 2 | use std::{ | 1 | use std::{ |
| 3 | fs::{DirEntry, Metadata}, | 2 | fs::{DirEntry, Metadata}, |
| 4 | path::{Path, PathBuf}, | 3 | path::{Path, PathBuf}, |
| @@ -6,11 +5,20 @@ use std::{ | |||
| 6 | 5 | ||
| 7 | use super::prelude::*; | 6 | use super::prelude::*; |
| 8 | 7 | ||
| 8 | /// Creates links | ||
| 9 | /// | ||
| 10 | /// If a link is created for a file that already had a link then the old link will be overwritten. | ||
| 11 | /// By default creating a link to a directory will recursively link all files under that | ||
| 12 | /// directory, to actually link a directory use the --directory flag. | ||
| 9 | #[derive(Clap)] | 13 | #[derive(Clap)] |
| 14 | #[clap(setting = AppSettings::ColoredHelp)] | ||
| 10 | pub struct Opts { | 15 | pub struct Opts { |
| 16 | /// Treats the paths as directories. This will create links to the actual directories instead | ||
| 17 | /// of recursively linking all files under them. | ||
| 11 | #[clap(long)] | 18 | #[clap(long)] |
| 12 | directory: bool, | 19 | directory: bool, |
| 13 | 20 | ||
| 21 | /// The paths to link. The last path is the destination. | ||
| 14 | paths: Vec<PathBuf>, | 22 | paths: Vec<PathBuf>, |
| 15 | } | 23 | } |
| 16 | 24 | ||
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 @@ | |||
| 1 | use clap::Clap; | ||
| 2 | use std::path::PathBuf; | 1 | use std::path::PathBuf; |
| 3 | 2 | ||
| 4 | use super::prelude::*; | 3 | use super::prelude::*; |
| 5 | 4 | ||
| 5 | /// Uninstalls links. (Removes symlinks). | ||
| 6 | /// | ||
| 7 | /// Uninstalling a link for a file that didnt have a link will do nothing. | ||
| 8 | /// Uninstalling a directory will recursively uninstall all files under it. | ||
| 9 | /// Symlinks are only deleted if they were pointing to the correct file. | ||
| 6 | #[derive(Clap)] | 10 | #[derive(Clap)] |
| 11 | #[clap(setting = AppSettings::ColoredHelp)] | ||
| 7 | pub struct Opts { | 12 | pub struct Opts { |
| 8 | /// The location where links will be uninstalled from. | 13 | /// The location where links will be uninstalled from. |
| 9 | /// Defaults to home directory. | 14 | /// Defaults to home directory. |
| 10 | #[clap(long)] | 15 | #[clap(long)] |
| 11 | install_base: Option<PathBuf>, | 16 | install_base: Option<PathBuf>, |
| 12 | 17 | ||
| 13 | /// The files/directories to uninstall | 18 | /// The files/directories to uninstall. |
| 14 | #[clap(required = true, min_values = 1)] | 19 | #[clap(required = true, min_values = 1)] |
| 15 | paths: Vec<PathBuf>, | 20 | paths: Vec<PathBuf>, |
| 16 | } | 21 | } |
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 @@ | |||
| 1 | use clap::Clap; | ||
| 2 | use std::{ | 1 | use std::{ |
| 3 | fs::{DirEntry, Metadata}, | 2 | fs::{DirEntry, Metadata}, |
| 4 | path::{Path, PathBuf}, | 3 | path::{Path, PathBuf}, |
| @@ -6,12 +5,19 @@ use std::{ | |||
| 6 | 5 | ||
| 7 | use super::prelude::*; | 6 | use super::prelude::*; |
| 8 | 7 | ||
| 8 | /// Unlinks files/directories. | ||
| 9 | /// | ||
| 10 | /// This will recursively remove links. If a path is a directory then it will remove all links | ||
| 11 | /// recursively. | ||
| 12 | /// The links are not uninstall by default, see the --uninstall parameter. | ||
| 9 | #[derive(Clap)] | 13 | #[derive(Clap)] |
| 14 | #[clap(setting = AppSettings::ColoredHelp)] | ||
| 10 | pub struct Opts { | 15 | pub struct Opts { |
| 11 | /// Specifies the install base if the links are also to be uninstalled. | 16 | /// Specify the install base if the links are also to be uninstalled. |
| 12 | #[clap(long)] | 17 | #[clap(long)] |
| 13 | uninstall: Option<PathBuf>, | 18 | uninstall: Option<PathBuf>, |
| 14 | 19 | ||
| 20 | /// The paths to unlink. | ||
| 15 | #[clap(required = true, min_values = 1)] | 21 | #[clap(required = true, min_values = 1)] |
| 16 | paths: Vec<PathBuf>, | 22 | paths: Vec<PathBuf>, |
| 17 | } | 23 | } |
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; | |||
| 7 | 7 | ||
| 8 | pub mod prelude { | 8 | pub mod prelude { |
| 9 | pub use super::Config; | 9 | pub use super::Config; |
| 10 | pub use clap::{AppSettings, Clap}; | ||
| 10 | pub use dotup::{Archive, Depot, DepotConfig, Link, LinkCreateParams, LinkID}; | 11 | pub use dotup::{Archive, Depot, DepotConfig, Link, LinkCreateParams, LinkID}; |
| 11 | } | 12 | } |
| 12 | 13 | ||
| @@ -23,7 +24,6 @@ use prelude::*; | |||
| 23 | const DEFAULT_DEPOT_NAME: &str = "depot.toml"; | 24 | const DEFAULT_DEPOT_NAME: &str = "depot.toml"; |
| 24 | 25 | ||
| 25 | #[derive(Clap)] | 26 | #[derive(Clap)] |
| 26 | #[clap(version = "0.1", author = "d464")] | ||
| 27 | #[clap(setting = AppSettings::ColoredHelp)] | 27 | #[clap(setting = AppSettings::ColoredHelp)] |
| 28 | struct Opts { | 28 | struct Opts { |
| 29 | /// Path to the depot file. | 29 | /// Path to the depot file. |
| @@ -37,8 +37,11 @@ struct Opts { | |||
| 37 | /// A level of verbosity, and can be used multiple times | 37 | /// A level of verbosity, and can be used multiple times |
| 38 | /// | 38 | /// |
| 39 | /// Level 0 - Warnings (Default) | 39 | /// Level 0 - Warnings (Default) |
| 40 | /// | ||
| 40 | /// Level 1 - Info | 41 | /// Level 1 - Info |
| 42 | /// | ||
| 41 | /// Level 2 - Debug | 43 | /// Level 2 - Debug |
| 44 | /// | ||
| 42 | /// Level 3 - Trace | 45 | /// Level 3 - Trace |
| 43 | #[clap(short, long, parse(from_occurrences))] | 46 | #[clap(short, long, parse(from_occurrences))] |
| 44 | verbose: i32, | 47 | verbose: i32, |
