From 6765e0864c26d7152ddc969c8b270551f104ff87 Mon Sep 17 00:00:00 2001 From: Denis Gorbachev <829578+DenisGorbachev@users.noreply.github.com> Date: Mon, 26 Aug 2024 13:06:43 +0700 Subject: [PATCH] feat: add create-rust-keybase-private-lib --- README.md | 1 + src/bin/create-rust-keybase-private-bin.rs | 7 ++----- src/bin/create-rust-keybase-private-lib.rs | 11 +++++++++++ src/lib.rs | 7 +++++++ 4 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 src/bin/create-rust-keybase-private-lib.rs diff --git a/README.md b/README.md index b70c65e..4d356f9 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,7 @@ All command arg options support the following substitutions: * `create-rust-github-public-bin` * `create-rust-github-public-lib` * `create-rust-keybase-private-bin` +* `create-rust-keybase-private-lib` ## Gratitude diff --git a/src/bin/create-rust-keybase-private-bin.rs b/src/bin/create-rust-keybase-private-bin.rs index c89a266..05fb455 100644 --- a/src/bin/create-rust-keybase-private-bin.rs +++ b/src/bin/create-rust-keybase-private-bin.rs @@ -2,13 +2,10 @@ use std::io::{stderr, stdout}; use clap::Parser; -use create_rust_github_repo::CreateRustGithubRepo; +use create_rust_github_repo::{set_keybase_defaults, CreateRustGithubRepo}; fn main() -> anyhow::Result<()> { - CreateRustGithubRepo::parse() - .repo_exists_cmd("keybase git list | grep \" {{name}} \"") - .repo_create_cmd("keybase git create {{name}}") - .repo_clone_cmd("git clone $(keybase git list | grep \" {{name}} \" | awk '{print $2}') {{dir}}") + set_keybase_defaults(CreateRustGithubRepo::parse()) .project_init_cmd("cargo init --bin") .run(&mut stdout(), &mut stderr(), None) } diff --git a/src/bin/create-rust-keybase-private-lib.rs b/src/bin/create-rust-keybase-private-lib.rs new file mode 100644 index 0000000..e725280 --- /dev/null +++ b/src/bin/create-rust-keybase-private-lib.rs @@ -0,0 +1,11 @@ +use std::io::{stderr, stdout}; + +use clap::Parser; + +use create_rust_github_repo::{set_keybase_defaults, CreateRustGithubRepo}; + +fn main() -> anyhow::Result<()> { + set_keybase_defaults(CreateRustGithubRepo::parse()) + .project_init_cmd("cargo init --lib") + .run(&mut stdout(), &mut stderr(), None) +} diff --git a/src/lib.rs b/src/lib.rs index 329d6f0..02f30d1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -365,6 +365,13 @@ fn check_status(status: ExitStatus) -> io::Result { } } +pub fn set_keybase_defaults(create_repo: CreateRustGithubRepo) -> CreateRustGithubRepo { + create_repo + .repo_exists_cmd("keybase git list | grep \" {{name}} \"") + .repo_create_cmd("keybase git create {{name}}") + .repo_clone_cmd("git clone $(keybase git list | grep \" {{name}} \" | awk '{print $2}') {{dir}}") +} + const CARGO_PKG_REPOSITORY: &str = env!("CARGO_PKG_REPOSITORY"); const SUPPORT_LINK_FIELD_NAME: &str = "support_link_probability"; const MEGABYTE: usize = 1048576;