svn integration
This commit is contained in:
parent
17301735c0
commit
71d1744d9b
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -825,7 +825,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "toru"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"clap",
|
||||
|
@ -76,7 +76,6 @@ Then you can run `toru new` to create your first task.
|
||||
- Keep track of completed date, and correctly update upon marking as complete or manual edit
|
||||
- Disallow removing it in a manual edit unless complete is also marked to false
|
||||
- Add to statistics
|
||||
- SVN integration
|
||||
- Statistics
|
||||
- Completed tasks over last x days
|
||||
- Improve formatting to terminal to make easier to read for `tracked` command
|
||||
|
17
src/main.rs
17
src/main.rs
@ -1,4 +1,4 @@
|
||||
mod git;
|
||||
mod vcs;
|
||||
mod edit;
|
||||
mod vault;
|
||||
mod error;
|
||||
@ -64,6 +64,11 @@ enum Command {
|
||||
Git {
|
||||
args : Vec<String>,
|
||||
},
|
||||
/// Run Subversion commands at the root of the vault.
|
||||
#[clap(trailing_var_arg=true)]
|
||||
Svn {
|
||||
args : Vec<String>,
|
||||
},
|
||||
/// Adds the recommended .gitignore file to the vault.
|
||||
#[clap(name="gitignore")]
|
||||
GitIgnore,
|
||||
@ -216,13 +221,17 @@ fn program() -> Result<(), error::Error> {
|
||||
}
|
||||
else if let Git { args } = command {
|
||||
let vault_folder = &config.current_vault()?.1;
|
||||
git::run_command(args, vault_folder)?;
|
||||
vcs::command(args, vcs::Vcs::Git, vault_folder)?;
|
||||
}
|
||||
else if command == GitIgnore {
|
||||
let vault_folder = &config.current_vault()?.1;
|
||||
git::create_gitignore(vault_folder)?;
|
||||
vcs::create_gitignore(vault_folder)?;
|
||||
println!("Default .gitignore file created");
|
||||
}
|
||||
else if let Svn { args } = command {
|
||||
let vault_folder = &config.current_vault()?.1;
|
||||
vcs::command(args, vcs::Vcs::Svn, vault_folder)?;
|
||||
}
|
||||
// Commands that require loading in the state.
|
||||
else {
|
||||
let vault_folder = &config.current_vault()?.1;
|
||||
@ -294,7 +303,7 @@ fn program() -> Result<(), error::Error> {
|
||||
println!("Deleted all discarded tasks");
|
||||
}
|
||||
// All commands which are dealt with in if let chain at start.
|
||||
Vault(_) | Config(_) | Git { args : _ } | Switch { name : _ } | GitIgnore => unreachable!(),
|
||||
Vault(_) | Config(_) | Git { args : _ } | Svn { args : _ } | Switch { name : _ } | GitIgnore => unreachable!(),
|
||||
}
|
||||
|
||||
state.save()?;
|
||||
|
@ -4,19 +4,23 @@ use std::fs;
|
||||
use std::path;
|
||||
use std::process;
|
||||
|
||||
pub fn run_command(args : Vec<String>, vault_folder : &path::Path) -> Result<(), error::Error> {
|
||||
pub enum Vcs {
|
||||
Git,
|
||||
Svn,
|
||||
}
|
||||
|
||||
let mut command = process::Command::new("git");
|
||||
pub fn command(args : Vec<String>, vcs : Vcs, vault_folder : &path::Path) -> Result<(), error::Error> {
|
||||
|
||||
let mut command = match vcs {
|
||||
Vcs::Git => process::Command::new("git"),
|
||||
Vcs::Svn => process::Command::new("svn"),
|
||||
};
|
||||
|
||||
let mut child = command
|
||||
.current_dir(vault_folder)
|
||||
// Force colour output even though run from other process.
|
||||
.args(["-c", "color.ui=always"])
|
||||
.args(args)
|
||||
.spawn()?;
|
||||
|
||||
// No point handling the potential error code as Git will report the error directly with more
|
||||
// info.
|
||||
let _ = child.wait()?;
|
||||
|
||||
Ok(())
|
Loading…
Reference in New Issue
Block a user