Skip to content

Commit

Permalink
Merge pull request #81 from xoac/nats-box-token
Browse files Browse the repository at this point in the history
Add auth-token flag. Group auth-token and certs into auth clap::ArgGroup
  • Loading branch information
spacejam authored Jul 21, 2020
2 parents 9dc50bc + 41ea1a6 commit b6e04c4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions examples/nats-box/main.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
use nats;
use quicli::prelude::*;
use structopt::StructOpt;
use structopt::{clap::ArgGroup, StructOpt};

/// NATS utility that can perform basic publish, subscribe, request and reply functions.
#[derive(Debug, StructOpt)]
#[structopt(group = ArgGroup::with_name("auth").required(false))]
struct Cli {
/// NATS server
#[structopt(long, short, default_value = "demo.nats.io")]
server: String,

/// User Credentials File
#[structopt(long = "creds")]
#[structopt(long = "creds", group = "auth")]
creds: Option<String>,
/// Server authorization token
#[structopt(long = "auth-token", group = "auth")]
auth_token: Option<String>,

/// Command: pub, sub, request, reply
#[structopt(subcommand)]
Expand All @@ -36,6 +40,8 @@ fn main() -> CliResult {

let opts = if let Some(creds_path) = args.creds {
nats::Options::with_credentials(creds_path)
} else if let Some(token) = args.auth_token {
nats::Options::with_token(&token)
} else {
nats::Options::new()
};
Expand Down

0 comments on commit b6e04c4

Please sign in to comment.