Skip to content

Commit

Permalink
csv
Browse files Browse the repository at this point in the history
  • Loading branch information
Will-well authored and will-we committed Aug 18, 2024
1 parent 5b7357a commit 2205b80
Show file tree
Hide file tree
Showing 3 changed files with 268 additions and 4 deletions.
230 changes: 229 additions & 1 deletion Cargo.lock

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

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[package]
name = "template"
name = "rustCli"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow="1.0.86"
anyhow="1.0.86"
clap = { version = "4.5.13", features = ["derive"] }
37 changes: 36 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
use clap::Parser;

#[derive(Parser, Debug)]
#[command(name = "rustCli", version, about, long_about = None)]
struct Opts {
#[command(subcommand)]
cmd: SubCommand,
}

#[derive(Parser, Debug)]
enum SubCommand {
#[command(name = "csv", about = "Subcommand for CSV operations")]
Csv(CsvOpts),
}

#[derive(Parser, Debug)]
struct CsvOpts {
/// Name of the person to greet
#[arg(short, long)]
input: String,

/// Output file name
#[arg(short, long, default_value = "output.json")]
output: String,

/// Delimiter to use for output file
#[arg(short, long, default_value = ",")]
delimiter: String,

#[arg(long, default_value_t = true)]
header: bool,
}

/// rustCli csv -i input.csv -o output.json -d ","
fn main() {
println!("Hello, world!");
let opts = Opts::parse();
println!("{:?}", opts);
}

0 comments on commit 2205b80

Please sign in to comment.