Skip to content

Commit

Permalink
add subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
Mon-ius committed Aug 26, 2023
1 parent 78da416 commit 48085f5
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
id: get
shell: bash
run: |
./target/release/core -a ${{ inputs.addr }} -p ${{ inputs.core }} >> $GITHUB_OUTPUT
./target/release/cli post ${{ inputs.addr }} ${{ inputs.core }} >> $GITHUB_OUTPUT
publish:
needs:
Expand Down
11 changes: 9 additions & 2 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
[package]
name = "core"
author = "monius <[email protected]>"
version = "0.1.0"
edition = "2021"

[dependencies]
clap = { version= "4.4.0", features=["derive"] }
clap = { version= "4.4.0", features=["derive"] }

[lib]
name = "kings"
path = "src/lib.rs"

[[bin]]
name = "cli"
path = "src/cli.rs"
24 changes: 24 additions & 0 deletions core/src/cli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use clap::{Parser, Subcommand};

#[derive(Parser)]
#[command(author, version)]
struct Cli {
#[command(subcommand)]
args: Kings,
}

#[derive(Subcommand)]
enum Kings {
Post {
addr: String,
promo: String,
},
}

fn main() -> std::io::Result<()>{
let cli = Cli::parse();
match cli.args {
Kings::Post { addr, promo } => println!("ref={:?}", promo)
}
Ok(())
}
Empty file added core/src/lib.rs
Empty file.
17 changes: 0 additions & 17 deletions core/src/main.rs

This file was deleted.

0 comments on commit 48085f5

Please sign in to comment.