aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Gattozzi <mgattozzi@gmail.com>2019-12-10 22:45:08 -0500
committerMichael Gattozzi <mgattozzi@gmail.com>2019-12-12 17:04:39 -0500
commit99aafb7242a8c1c74882969fb9ced28e099d3f4b (patch)
tree884a314e755ac866cdf2087dee081ec141a9dbcd
parent44ace0edbf9d6cd440c09f96b0eb0b7d141ac779 (diff)
Extend ds with config subcomand
This commit utilizes configamajig to allow creating configs for a repo and the user themselves as well as checking what those values are.
-rw-r--r--Cargo.lock1
-rw-r--r--Cargo.toml1
-rw-r--r--src/main.rs55
3 files changed, 57 insertions, 0 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 5441bb4..3b3d24a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -230,6 +230,7 @@ name = "dev-suite"
version = "0.1.0"
dependencies = [
"anyhow 1.0.22 (registry+https://github.com/rust-lang/crates.io-index)",
+ "configamajig 0.1.0",
"dialoguer 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"paw 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"shared 0.1.0",
diff --git a/Cargo.toml b/Cargo.toml
index e65a7bd..083e992 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,6 +13,7 @@ path = "src/main.rs"
anyhow = "1.0"
paw = "1.0"
shared = { path = "shared" }
+configamajig = { path = "configamajig" }
structopt = { version = "0.3", features = ["paw"] }
dialoguer = "0.5"
which = "3.1"
diff --git a/src/main.rs b/src/main.rs
index a1fac85..8e2bf5f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -3,6 +3,7 @@ use anyhow::{
format_err,
Result,
};
+use configamajig::*;
use dialoguer::{
theme::ColorfulTheme,
Checkboxes,
@@ -19,6 +20,40 @@ enum Args {
Update,
/// Initialize the repo to use dev-suite and it's tools
Init,
+ /// Commands for configuration of dev-suite
+ Config(Config),
+}
+
+#[derive(structopt::StructOpt)]
+/// dev-suite config commands
+enum Config {
+ /// dev-suite config commands for the current user
+ User(User),
+ /// dev-suite config commands for the current repo
+ Repo(Repo),
+}
+
+#[derive(structopt::StructOpt)]
+enum User {
+ /// Initialize the user with a name
+ Init { name: String },
+ /// Show the current user
+ Show,
+}
+
+#[derive(structopt::StructOpt)]
+enum Repo {
+ /// Initialize the repo with a config
+ Init,
+ /// Show the repo config
+ Show,
+ /// Add someone as a maintainer
+ Add(Add),
+}
+#[derive(structopt::StructOpt)]
+enum Add {
+ /// Make self the maintainer
+ Me,
}
#[paw::main]
@@ -27,6 +62,19 @@ fn main(args: Args) {
Args::Init => init(),
Args::Update => unimplemented!(),
Args::Install => unimplemented!(),
+ Args::Config(conf) => match conf {
+ Config::User(user) => match user {
+ User::Init { name } => create_user_config(name),
+ User::Show => show_user_config(),
+ },
+ Config::Repo(repo) => match repo {
+ Repo::Init => create_repo_config(),
+ Repo::Show => show_repo_config(),
+ Repo::Add(add) => match add {
+ Add::Me => add_self_to_maintainers(),
+ },
+ },
+ },
} {
eprintln!("{}", e);
std::process::exit(1);
@@ -55,6 +103,13 @@ fn init() -> Result<()> {
if selections.is_empty() {
println!("Nothing selected. dev-suite not enabled in this repository.");
} else {
+ create_repo_config()?;
+ add_self_to_maintainers().map_err(|_| {
+ format_err!(
+ "It looks like this is your first time using dev-suite. Initialize your \
+ config with 'ds config user <name>' then rerun 'ds init'."
+ )
+ })?;
for selection in selections {
match selection {
Tools::Hooked => {