diff options
Diffstat (limited to 'dotup_cli/src/commands')
| -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 |
5 files changed, 36 insertions, 10 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 | } |
