generated from pure_sagacity/rust-starter
added a little bit of the commands
This commit is contained in:
Generated
+1288
-12
File diff suppressed because it is too large
Load Diff
@@ -2,9 +2,13 @@
|
|||||||
name = "cli"
|
name = "cli"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
authors = ["Maaz Khokhar "]
|
authors = ["idle_river <khokharmaaz@gmail.com>"]
|
||||||
description = "An opensource secrets management and distribution platform"
|
description = "An opensource secrets management and distribution platform"
|
||||||
license = "GLP-3.0"
|
license = "GLP-3.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tokio = { version = "1.52.3", features = ["full"] }
|
tokio = { version = "1.52.3", features = ["full"] }
|
||||||
|
clap = { version = "4.6.1", features = ["derive", "cargo"] }
|
||||||
|
keyring = "4.1.4"
|
||||||
|
colored = "3.1.1"
|
||||||
|
git-version = "0.3"
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
use clap::{Args, Parser, Subcommand};
|
||||||
|
|
||||||
|
#[derive(Parser)]
|
||||||
|
#[clap(
|
||||||
|
name = "Harbor",
|
||||||
|
version,
|
||||||
|
about = "An open source secrets management and distribution platform"
|
||||||
|
)]
|
||||||
|
#[command(disable_version_flag = true)]
|
||||||
|
pub struct Cli {
|
||||||
|
#[arg(short = 'v', long, help = "Print version")]
|
||||||
|
pub version: bool,
|
||||||
|
|
||||||
|
#[command(subcommand)]
|
||||||
|
pub command: Option<Commands>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Subcommand)]
|
||||||
|
pub enum Commands {
|
||||||
|
Inject(InjectArgs),
|
||||||
|
Shell {},
|
||||||
|
Add {},
|
||||||
|
Setup {},
|
||||||
|
List {},
|
||||||
|
Project {
|
||||||
|
#[command(subcommand)]
|
||||||
|
command: ProjectCommands,
|
||||||
|
},
|
||||||
|
Config {
|
||||||
|
#[command(subcommand)]
|
||||||
|
command: ConfigCommands,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Args, Debug)]
|
||||||
|
pub struct InjectArgs {
|
||||||
|
#[arg(short, long)]
|
||||||
|
pub verbose: bool,
|
||||||
|
|
||||||
|
#[arg(trailing_var_arg = true, allow_hyphen_values = true)]
|
||||||
|
pub after: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Subcommand)]
|
||||||
|
pub enum ProjectCommands {
|
||||||
|
List {},
|
||||||
|
Create { name: String },
|
||||||
|
Delete { name: String },
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Subcommand)]
|
||||||
|
pub enum ConfigCommands {
|
||||||
|
List {},
|
||||||
|
Create { project: String, name: String },
|
||||||
|
Delete { project: String, name: String },
|
||||||
|
}
|
||||||
+30
-1
@@ -1,3 +1,32 @@
|
|||||||
|
use std::process;
|
||||||
|
|
||||||
|
use clap::Parser;
|
||||||
|
use clap::crate_version;
|
||||||
|
use cli::Cli;
|
||||||
|
use colored::*;
|
||||||
|
use git_version::git_version;
|
||||||
|
|
||||||
|
const GIT_VERSION: &str = git_version!();
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Hello, world!");
|
let cli = Cli::parse();
|
||||||
|
|
||||||
|
if cli.version {
|
||||||
|
let top_msg = format!("Harbor version {}", crate_version!().green()).bright_blue();
|
||||||
|
let bottom_msg =
|
||||||
|
format!("An open source secrets management and distribution platform.").blue();
|
||||||
|
let commit_msg = format!("Git commit {}", GIT_VERSION).dimmed();
|
||||||
|
|
||||||
|
println!("{}\n{}\n{}", top_msg, bottom_msg, commit_msg);
|
||||||
|
process::exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if cli.command.is_none() {
|
||||||
|
println!(
|
||||||
|
"{}\n{}",
|
||||||
|
"No command was entered.".red(),
|
||||||
|
"Exiting...".dimmed()
|
||||||
|
);
|
||||||
|
process::exit(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user