mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 12:12:00 -06:00
Enable usage of auth flags behind login command
This commit is contained in:
parent
c2e953043e
commit
61766c74fa
4 changed files with 59 additions and 33 deletions
|
|
@ -2,6 +2,7 @@ use crate::utils::context::Context;
|
|||
use crate::Execute;
|
||||
use anyhow::bail;
|
||||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use crunchyroll_rs::crunchyroll::SessionToken;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
|
@ -9,7 +10,9 @@ use std::path::PathBuf;
|
|||
#[derive(Debug, clap::Parser)]
|
||||
#[clap(about = "Save your login credentials persistent on disk")]
|
||||
pub struct Login {
|
||||
#[arg(help = "Remove your stored credentials (instead of save them)")]
|
||||
#[clap(flatten)]
|
||||
pub login_method: LoginMethod,
|
||||
#[arg(help = "Remove your stored credentials (instead of saving them)")]
|
||||
#[arg(long)]
|
||||
pub remove: bool,
|
||||
}
|
||||
|
|
@ -36,6 +39,24 @@ impl Execute for Login {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Parser)]
|
||||
pub struct LoginMethod {
|
||||
#[arg(
|
||||
help = "Login with credentials (username or email and password). Must be provided as user:password"
|
||||
)]
|
||||
#[arg(long)]
|
||||
pub credentials: Option<String>,
|
||||
#[arg(help = "Login with the etp-rt cookie")]
|
||||
#[arg(
|
||||
long_help = "Login with the etp-rt cookie. This can be obtained when you login on crunchyroll.com and extract it from there"
|
||||
)]
|
||||
#[arg(long)]
|
||||
pub etp_rt: Option<String>,
|
||||
#[arg(help = "Login anonymously / without an account")]
|
||||
#[arg(long, default_value_t = false)]
|
||||
pub anonymous: bool,
|
||||
}
|
||||
|
||||
pub fn session_file_path() -> Option<PathBuf> {
|
||||
dirs::config_dir().map(|config_dir| config_dir.join("crunchy-cli").join("session"))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue