Skip to content

Commit

Permalink
feat!: add --dry-run, add command output, add shell arguments, implem…
Browse files Browse the repository at this point in the history
…ent the support message
  • Loading branch information
DenisGorbachev committed Jul 24, 2024
1 parent 649230d commit 4ecef31
Show file tree
Hide file tree
Showing 10 changed files with 328 additions and 97 deletions.
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ announcement = ""

[dependencies]
anyhow = "1.0.86"
clap = { version = "4.3.24", features = ["derive"] }
clap = { version = "4.3.24", features = ["derive", "env"] }
derive_setters = "0.1.6"
derive-new = "0.6.0"
fs_extra = "1.3.0"
67 changes: 57 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,34 +53,81 @@ Usage: create-rust-github-repo [OPTIONS] --name <NAME>
Options:
-n, --name <NAME>
Repository name
-d, --dir <DIR>
Target directory for cloning the repository (must include the repo name) (defaults to "{current_dir}/{repo_name}") (see also: --workspace)
-w, --workspace <WORKSPACE>
Parent of the target directory for cloning the repository (must NOT include the repo name). If this option is specified, then the repo is cloned to "{workspace}/{repo_name}". The --dir option overrides this option
--shell-cmd <SHELL_CMD>
Shell to use for executing commands [default: /bin/sh]
Shell to use for executing commands
[default: /bin/sh]
--shell-args <SHELL_ARGS>
Shell args to use for executing commands (note that '-c' is always passed as last arg)
-c, --copy-configs-from <COPY_CONFIGS_FROM>
Source directory for config paths
--configs <CONFIGS>
Config paths separated by comma (relative to `copy_configs_from`) (only applies if `copy_configs_from` is specified) (supports files and directories)
--repo-exists-cmd <REPO_EXISTS_CMD>
Shell command to check if repo exists (supports substitutions - see help below) [default: "gh repo view --json nameWithOwner {{name}} 2>/dev/null"]
Shell command to check if repo exists (supports substitutions - see help below)
[default: "gh repo view --json nameWithOwner {{name}} 2>/dev/null"]
--repo-create-cmd <REPO_CREATE_CMD>
Shell command to create a repo (supports substitutions - see help below) [default: "gh repo create --private {{name}}"]
Shell command to create a repo (supports substitutions - see help below)
[default: "gh repo create --private {{name}}"]
--repo-clone-cmd <REPO_CLONE_CMD>
Shell command to clone a repo (supports substitutions - see help below) [default: "gh repo clone {{name}} {{dir}}"]
Shell command to clone a repo (supports substitutions - see help below)
[default: "gh repo clone {{name}} {{dir}}"]
--project-init-cmd <PROJECT_INIT_CMD>
Shell command to initialize a project (supports substitutions - see help below) [default: "cargo init"]
Shell command to initialize a project (supports substitutions - see help below)
[default: "cargo init"]
--project-test-cmd <PROJECT_TEST_CMD>
Shell command to test a project (supports substitutions - see help below) [default: "cargo test"]
Shell command to test a project (supports substitutions - see help below)
[default: "cargo test"]
--repo-add-args <REPO_ADD_ARGS>
Shell command to add new files (supports substitutions - see help below) [default: "git add ."]
Shell command to add new files (supports substitutions - see help below)
[default: "git add ."]
--repo-commit-args <REPO_COMMIT_ARGS>
Shell command to make a commit (supports substitutions - see help below) [default: "git commit -m \"Setup project\""]
Shell command to make a commit (supports substitutions - see help below)
[default: "git commit -m \"Setup project\""]
--repo-push-args <REPO_PUSH_ARGS>
Shell command to push the commit (supports substitutions - see help below) [default: "git push"]
Shell command to push the commit (supports substitutions - see help below)
[default: "git push"]
-s, --support-link-probability <SUPPORT_LINK_PROBABILITY>
The probability of seeing a support link in a single execution of the command is `1 / {{this-field-value}}`.
Set it to 0 to disable the support link.
[env: SUPPORT_LINK_PROBABILITY=]
[default: 1]
--dry-run
Don't actually execute commands that modify the data, only print them (note that read-only commands will still be executed)
-h, --help
Print help
Print help (see a summary with '-h')
-V, --version
Print version
Expand Down
4 changes: 3 additions & 1 deletion src/bin/create-rust-github-private-bin.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::io::{stderr, stdout};

use clap::Parser;

use create_rust_github_repo::CreateRustGithubRepo;
Expand All @@ -6,5 +8,5 @@ fn main() -> anyhow::Result<()> {
CreateRustGithubRepo::parse()
.repo_create_cmd("gh repo create --private {{name}}")
.project_init_cmd("cargo init --bin")
.run()
.run(&mut stdout(), &mut stderr(), None)
}
4 changes: 3 additions & 1 deletion src/bin/create-rust-github-private-lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::io::{stderr, stdout};

use clap::Parser;

use create_rust_github_repo::CreateRustGithubRepo;
Expand All @@ -6,5 +8,5 @@ fn main() -> anyhow::Result<()> {
CreateRustGithubRepo::parse()
.repo_create_cmd("gh repo create --private {{name}}")
.project_init_cmd("cargo init --lib")
.run()
.run(&mut stdout(), &mut stderr(), None)
}
4 changes: 3 additions & 1 deletion src/bin/create-rust-github-public-bin.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::io::{stderr, stdout};

use clap::Parser;

use create_rust_github_repo::CreateRustGithubRepo;
Expand All @@ -6,5 +8,5 @@ fn main() -> anyhow::Result<()> {
CreateRustGithubRepo::parse()
.repo_create_cmd("gh repo create --public {{name}}")
.project_init_cmd("cargo init --bin")
.run()
.run(&mut stdout(), &mut stderr(), None)
}
4 changes: 3 additions & 1 deletion src/bin/create-rust-github-public-lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::io::{stderr, stdout};

use clap::Parser;

use create_rust_github_repo::CreateRustGithubRepo;
Expand All @@ -6,5 +8,5 @@ fn main() -> anyhow::Result<()> {
CreateRustGithubRepo::parse()
.repo_create_cmd("gh repo create --public {{name}}")
.project_init_cmd("cargo init --lib")
.run()
.run(&mut stdout(), &mut stderr(), None)
}
4 changes: 3 additions & 1 deletion src/bin/create-rust-keybase-private-bin.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::io::{stderr, stdout};

use clap::Parser;

use create_rust_github_repo::CreateRustGithubRepo;
Expand All @@ -8,5 +10,5 @@ fn main() -> anyhow::Result<()> {
.repo_create_cmd("keybase git create {{name}}")
.repo_clone_cmd("git clone $(keybase git list | grep \" {{name}} \" | awk '{print $2}') {{dir}}")
.project_init_cmd("cargo init --bin")
.run()
.run(&mut stdout(), &mut stderr(), None)
}
Loading

0 comments on commit 4ecef31

Please sign in to comment.