mirror of
https://github.com/pesde-pkg/pesde.git
synced 2024-12-12 11:00:36 +00:00
fix: improve login command behaviour
This commit is contained in:
parent
30c9be8366
commit
836870f1ce
1 changed files with 3 additions and 6 deletions
|
@ -20,11 +20,7 @@ pub struct LoginCommand {
|
||||||
/// The index to use. Defaults to `default`, or the configured default index if current directory doesn't have a manifest
|
/// The index to use. Defaults to `default`, or the configured default index if current directory doesn't have a manifest
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
index: Option<String>,
|
index: Option<String>,
|
||||||
|
|
||||||
/// Whether to not prefix the token with `Bearer `
|
|
||||||
#[arg(short, long, conflicts_with = "token")]
|
|
||||||
no_bearer: bool,
|
|
||||||
|
|
||||||
/// The token to use for authentication, skipping login
|
/// The token to use for authentication, skipping login
|
||||||
#[arg(short, long, conflicts_with = "index")]
|
#[arg(short, long, conflicts_with = "index")]
|
||||||
token: Option<String>,
|
token: Option<String>,
|
||||||
|
@ -185,12 +181,13 @@ impl LoginCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run(self, project: Project, reqwest: reqwest::blocking::Client) -> anyhow::Result<()> {
|
pub fn run(self, project: Project, reqwest: reqwest::blocking::Client) -> anyhow::Result<()> {
|
||||||
|
let token_given = self.token.is_some();
|
||||||
let token = match self.token {
|
let token = match self.token {
|
||||||
Some(token) => token,
|
Some(token) => token,
|
||||||
None => self.authenticate_device_flow(&project, &reqwest)?,
|
None => self.authenticate_device_flow(&project, &reqwest)?,
|
||||||
};
|
};
|
||||||
|
|
||||||
let token = if self.no_bearer {
|
let token = if token_given {
|
||||||
println!("set token");
|
println!("set token");
|
||||||
token
|
token
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue