diff --git a/Cargo.lock b/Cargo.lock index 9cd03bf..2725081 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1539,7 +1539,7 @@ dependencies = [ [[package]] name = "tmpo" -version = "1.2.0" +version = "1.2.2" dependencies = [ "clap 3.0.0-beta.1 (git+https://github.com/clap-rs/clap/)", "colored 1.9.3 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 069bbb6..024c68d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tmpo" -version = "1.2.0" +version = "1.2.2" authors = ["Thomas Pöhlmann "] edition = "2018" diff --git a/readme.md b/readme.md index ddee4a0..2aaec0d 100644 --- a/readme.md +++ b/readme.md @@ -70,37 +70,29 @@ Come over to [Twitter](https://twitter.com/perryrh0dan1) to share your thoughts ## Usage -### Cli +### CLI ``` bash -tmpo init example --repository default --template typescript --directory . +tmpo init example --repository default --template typescript --directory . --remote https://github.com/perryrh0dan/2fa ``` ### Repositories -A repository is a folder that contains up to n different templates. A repository can be connected with a remote git repository. Templates are then automaticly synced. Repositories are located in the 'template_dir'. +A repository is a folder that contains up to n different templates. A repository can be connected with a remote git repository. Templates are then automaticly synced. Repositories are located in the 'template_dir'. -### Templates - -Templates can be configured with a `meta.json` in the template root. The official template repository with detailed instructions can be found [here](https://github.com/perryrh0dan/templates). - -#### Format +To add a new repository use the `repository subcommand` and follow the instructions on the screen. -``` json -{ - "name": "", - "extend": [""], - "exclude": [""], - "scripts": { - "before_install": "", - "after_install": "" - } -} +``` bash +tmpo repository add ``` -For a detailed description how to create and maintain templates have a look at the default tempaltes [repository](https://github.com/perryrh0dan/templates) +### Templates + +Templates can be configured with a `meta.json` in the template root. +For a detailed description how to create and maintain templates have a look at the instructions and default templates [repository](https://github.com/perryrh0dan/templates) ## Configuration +The configuration file should only be changed by experienced users. To configure tmpo navigate to the ~/.tmpo/config.yaml file and modify any of the options to match your own preference. To reset back to the default values, simply delete the config file from your home directory. @@ -120,51 +112,6 @@ The following illustrates all the available options with their respective defaul password: ~ ``` -### In Detail - -#### templates_dir -- Type: String -- Default: $HOME/.tmpo/templates - -Filesystem path where all the templates are stored. - -#### templates_repo -- Type: String -- Default: $HOME/.tmpo/templates - -##### url -- Type: String -- Default: $HOME/.tmpo/templates - -Url of the repository where templates are managed. - -##### auth -- Type: String -- Default: none -- Values: `none`, `token` - -##### token -- Type: String -- Default: none - -Access token is only used when auth type is token - -##### username -- Type: String -- Default: none - -Coming soon - -##### password -- Type: String -- Default: none - -##### privatekey - -Coming soon - -##### - ## Development ### Build diff --git a/src/config/mod.rs b/src/config/mod.rs index 9ec8c80..d41e57e 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -13,8 +13,8 @@ extern crate serde_yaml; #[derive(serde::Serialize, serde::Deserialize, Debug)] pub struct Config { - pub templates_dir: String, - pub templates_repositories: Vec, + pub template_dir: String, + pub template_repositories: Vec, } #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] @@ -28,7 +28,7 @@ impl Config { pub fn get_repositories(&self) -> Vec { let mut repositories = Vec::::new(); - for entry in self.templates_repositories.iter() { + for entry in self.template_repositories.iter() { repositories.push(String::from(&entry.name)); } @@ -36,7 +36,7 @@ impl Config { } pub fn get_repository_config(&self, name: &str) -> Option { - let config = self.templates_repositories.iter().find(|&x| utils::lowercase(&x.name) == utils::lowercase(&name)); + let config = self.template_repositories.iter().find(|&x| utils::lowercase(&x.name) == utils::lowercase(&name)); if config.is_some() { return Some(config.unwrap().clone()); @@ -56,7 +56,7 @@ pub fn init() -> Result { let config = load_config()?; - ensure_template_dir(&config.templates_dir)?; + ensure_template_dir(&config.template_dir)?; Ok(config) } @@ -143,8 +143,8 @@ fn get_default_config() -> Config { }); let config = Config { - templates_dir: template_dir, - templates_repositories: repo_options, + template_dir: template_dir, + template_repositories: repo_options, }; return config; diff --git a/src/repository/mod.rs b/src/repository/mod.rs index 48089a8..109b5b1 100644 --- a/src/repository/mod.rs +++ b/src/repository/mod.rs @@ -33,7 +33,7 @@ impl Repository { Option::None => return Err(RepositoryError::NotFound), }; - let directory = String::from(&config.templates_dir) + "/" + &utils::lowercase(name); + let directory = String::from(&config.template_dir) + "/" + &utils::lowercase(name); let mut repository = Repository { directory: directory, @@ -52,7 +52,7 @@ impl Repository { } pub fn delete_repository(config: &Config, name: &str) -> Result<(), Error> { - let mut repository_dir = PathBuf::from(&config.templates_dir); + let mut repository_dir = PathBuf::from(&config.template_dir); repository_dir.push(&utils::lowercase(name)); log::info!("Delete repository directory {}", &repository_dir.to_owned().to_str().unwrap()); @@ -114,7 +114,7 @@ impl Repository { } fn ensure_repository_dir(&self, config: &Config) -> Result<(), Error> { - let mut directory = PathBuf::from(&config.templates_dir); + let mut directory = PathBuf::from(&config.template_dir); directory.push(&utils::lowercase(&self.config.name)); let r = fs::create_dir_all(&directory); match r { @@ -131,7 +131,7 @@ impl Repository { git::GitError::AddRemoteError => println!("Add Remote Error"), }, }; - + match git::update(&directory, &self.config.git_options) { Ok(()) => (), Err(_e) => out::error::update_templates(),