-
-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "distcli" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
clap = {version="4.0.32", features=["derive"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM rust:1.67.1 as build-env | ||
WORKDIR /app | ||
COPY . /app | ||
RUN cargo build --release | ||
|
||
FROM gcr.io/distroless/cc | ||
COPY --from=build-env /app/target/release/distcli / | ||
CMD ["./distcli"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
format: | ||
cargo fmt --quiet | ||
|
||
lint: | ||
@rustup component add clippy 2> /dev/null | ||
cargo clippy --quiet | ||
|
||
test: | ||
cargo test --quiet | ||
|
||
|
||
run: | ||
cargo run -- greet --name bob | ||
|
||
all: format lint test run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Run the 27mb binary do this: | ||
|
||
`docker run -it --rm 61503cf1e0b3 ./distcli greet --name bob` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//A command-line tool to play Marco Polo | ||
use clap::Parser; | ||
|
||
#[derive(Parser)] | ||
#[clap(version = "1.0", author = "Noah Gift", about = "hello world")] | ||
struct Cli { | ||
#[clap(subcommand)] | ||
command: Option<Commands>, | ||
} | ||
|
||
#[derive(Parser)] | ||
enum Commands { | ||
#[clap(version = "1.0", author = "Noah Gift")] | ||
Greet { | ||
#[clap(short, long)] | ||
name: String, | ||
}, | ||
} | ||
|
||
fn main() { | ||
let args = Cli::parse(); | ||
match args.command { | ||
Some(Commands::Greet { name }) => { | ||
println!("Hello, {}!", name); | ||
} | ||
None => println!("No subcommand was used"), | ||
} | ||
} |