diff --git a/README.md b/README.md index 07b1df8..350efb7 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ # TODO: +- [ ] split subcommands to functions - [ ] reorganize cmd option for storage - [ ] use subcommand diff --git a/src/main.rs b/src/main.rs index 65c5a7e..ca1b9d3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -373,6 +373,7 @@ fn main() -> Result<()> { for (k, storage) in &storages { println!("{}: {}", k, storage); println!(" {}", storage.mount_path(&device, &storages)?.display()); + // println!("{}: {}", storage.shorttypename(), storage.name()); // TODO } } StorageCommands::Bind { diff --git a/src/storages.rs b/src/storages.rs index 912e632..7e3ece6 100644 --- a/src/storages.rs +++ b/src/storages.rs @@ -27,7 +27,25 @@ pub enum Storage { Online(OnlineStorage), } -impl Storage {} +impl Storage { + /// Full type name like "PhysicalStorage". + pub fn typename(&self) -> &str { + match self { + Self::PhysicalStorage(_) => "PhysicalStorage", + Self::SubDirectory(_) => "SubDirectory", + Self::Online(_) => "OnlineStorage", + } + } + + /// Short type name with one letter like "P". + pub fn shorttypename(&self) -> &str { + match self { + Self::PhysicalStorage(_) => "P", + Self::SubDirectory(_) => "S", + Self::Online(_) => "O", + } + } +} impl StorageExt for Storage { fn name(&self) -> &String {