diff options
| author | Mel <einebeere@gmail.com> | 2021-09-20 22:25:55 +0200 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2021-09-20 22:25:55 +0200 |
| commit | c25d22681f9bc6ddba512895182af0ce0252731b (patch) | |
| tree | eadcdec7d0b4d26d59e77169bd89b8db13e22fb6 /src/actions/mod.rs | |
| parent | 8bcbf51cf4f7924600eae39db67ff653b48ad95d (diff) | |
| download | ka-c25d22681f9bc6ddba512895182af0ce0252731b.tar.zst ka-c25d22681f9bc6ddba512895182af0ce0252731b.zip | |
Split out common logic
Diffstat (limited to 'src/actions/mod.rs')
| -rw-r--r-- | src/actions/mod.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/actions/mod.rs b/src/actions/mod.rs new file mode 100644 index 0000000..588ce8f --- /dev/null +++ b/src/actions/mod.rs @@ -0,0 +1,30 @@ +mod create; +mod shift; +mod update; + +use std::path::{Path, PathBuf}; + +pub use create::create; +pub use shift::shift; +pub use update::update; + +pub struct ActionOptions { + pub repository_path: PathBuf, +} + +impl ActionOptions { + pub fn from_path(path: &str) -> Self { + ActionOptions { + repository_path: Path::new(path).to_path_buf(), + } + } + + pub fn from_pwd() -> Result<Self, ()> { + let current_path = std::env::current_dir(); + if let Ok(repository_path) = current_path { + Ok(ActionOptions { repository_path }) + } else { + Err(()) + } + } +} |
