Skip to content

Commit

Permalink
Rename url -> api-url and auth-token -> api-token
Browse files Browse the repository at this point in the history
The parallel structure is a lot clearer this way. This also removes the
short version of the api-token argument; short argument names are not
in plentiful supply, and the caller should prefer passing it via
environment anyway.

Signed-off-by: Ryan Gonzalez <[email protected]>
  • Loading branch information
refi64 committed Jun 20, 2023
1 parent 52b4f3d commit 272fb3b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
14 changes: 7 additions & 7 deletions aptly-rest/examples/aptlyrestcli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@ enum Action {

#[derive(clap::Parser, Debug)]
struct Opts {
#[clap(short, long, default_value = "http://localhost:8080")]
url: Url,
#[clap(short = 'u', long, default_value = "http://localhost:8080")]
api_url: Url,
/// Authentication token for the API
#[clap(short, long, env = "APTLY_AUTH_TOKEN")]
auth_token: Option<String>,
#[clap(long, env = "APTLY_API_TOKEN")]
api_token: Option<String>,
#[clap(subcommand)]
action: Action,
}
Expand All @@ -171,10 +171,10 @@ struct Opts {
async fn main() -> Result<()> {
let opts = Opts::parse();

let aptly = if let Some(token) = opts.auth_token {
AptlyRest::new_with_token(opts.url, &token)?
let aptly = if let Some(token) = opts.api_token {
AptlyRest::new_with_token(opts.api_url, &token)?
} else {
AptlyRest::new(opts.url)
AptlyRest::new(opts.api_url)
};

match opts.action {
Expand Down
14 changes: 7 additions & 7 deletions aptlyctl/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ struct Opts {
#[clap(subcommand)]
command: Command,
/// Url for the aptly rest API endpoint
#[clap(short, long, default_value = "http://localhost:8080")]
url: url::Url,
#[clap(short = 'u', long, default_value = "http://localhost:8080")]
api_url: url::Url,
/// Authentication token for the API
#[clap(short, long, env = "APTLY_AUTH_TOKEN")]
auth_token: Option<String>,
#[clap(long, env = "APTLY_API_TOKEN")]
api_token: Option<String>,
}

#[tokio::main]
Expand All @@ -63,10 +63,10 @@ async fn main() -> Result<ExitCode> {
.init();
color_eyre::install().unwrap();
let opts = Opts::parse();
let aptly = if let Some(token) = opts.auth_token {
AptlyRest::new_with_token(opts.url, &token)?
let aptly = if let Some(token) = opts.api_token {
AptlyRest::new_with_token(opts.api_url, &token)?
} else {
AptlyRest::new(opts.url)
AptlyRest::new(opts.api_url)
};

match opts.command {
Expand Down
12 changes: 6 additions & 6 deletions obs2aptly/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ use tracing_subscriber::prelude::*;
struct Opts {
/// Url for the aptly rest api endpoint
#[clap(short, long, default_value = "http://localhost:8080")]
url: url::Url,
api_url: url::Url,
/// Authentication token for the API
#[clap(short, long, env = "APTLY_AUTH_TOKEN")]
auth_token: Option<String>,
#[clap(long, env = "APTLY_API_TOKEN")]
api_token: Option<String>,
/// Repo in aptly
aptly_repo: String,
/// Directory with obs repositories
Expand All @@ -33,10 +33,10 @@ async fn main() -> Result<()> {
.init();
color_eyre::install().unwrap();
let opts = Opts::parse();
let aptly = if let Some(token) = opts.auth_token {
AptlyRest::new_with_token(opts.url, &token)?
let aptly = if let Some(token) = opts.api_token {
AptlyRest::new_with_token(opts.api_url, &token)?
} else {
AptlyRest::new(opts.url)
AptlyRest::new(opts.api_url)
};

let aptly_contents = AptlyContent::new_from_aptly(&aptly, opts.aptly_repo).await?;
Expand Down

0 comments on commit 272fb3b

Please sign in to comment.