-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from gierens/feat-9-cli-password-auth
Add Password Authentication to CLI This adds password authentication to as alternative to API key authentication to the CLI program. It also adds corresponding documentation in the README. It furthermore adds Debug derivation on all parser and (sub)command structs and enums, and the authentication-strategy list command. Resolves #9
- Loading branch information
Showing
14 changed files
with
144 additions
and
22 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
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
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
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,61 @@ | ||
use crate::common::Execute; | ||
use clap::Subcommand; | ||
use std::error::Error; | ||
use tabled::{builder::Builder, settings::Style}; | ||
|
||
#[derive(Subcommand, Debug)] | ||
pub(crate) enum AuthenticationStrategyCommand { | ||
#[clap(about = "List authentication strategies")] | ||
List {}, | ||
} | ||
|
||
impl Execute for AuthenticationStrategyCommand { | ||
fn execute(&self, api: wikijs::Api) -> Result<(), Box<dyn Error>> { | ||
match self { | ||
AuthenticationStrategyCommand::List {} => { | ||
authentication_strategy_list(api) | ||
} | ||
} | ||
} | ||
} | ||
|
||
fn authentication_strategy_list( | ||
api: wikijs::Api, | ||
) -> Result<(), Box<dyn Error>> { | ||
let providers = api.authentication_strategy_list()?; | ||
let mut builder = Builder::new(); | ||
builder.push_record([ | ||
"key", | ||
// "props", | ||
"title", | ||
// "description", | ||
"is_available", | ||
// "use_form", | ||
// "username_type", | ||
// "logo", | ||
// "color", | ||
// "website", | ||
// "icon", | ||
]); | ||
for provider in providers { | ||
builder.push_record([ | ||
provider.key.as_str(), | ||
// provider.props.as_str(), | ||
provider.title.as_str(), | ||
// provider.description.as_str(), | ||
match provider.is_available { | ||
Some(true) => "true", | ||
Some(false) => "false", | ||
None => "", | ||
}, | ||
// provider.use_form.to_string().as_str(), | ||
// provider.username_type.as_str(), | ||
// provider.logo.as_str(), | ||
// provider.color.as_str(), | ||
// provider.website.as_str(), | ||
// provider.icon.as_str(), | ||
]); | ||
} | ||
println!("{}", builder.build().with(Style::rounded())); | ||
Ok(()) | ||
} |
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
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
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
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
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
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
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
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
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
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