diff --git a/src/commands/cli.rs b/src/commands/cli.rs index fdd5adeb..1498fb13 100644 --- a/src/commands/cli.rs +++ b/src/commands/cli.rs @@ -74,6 +74,10 @@ pub fn main(options: &Options) -> Result<(), anyhow::Error> { let cmdopt = init_command_opts(options)?; branch::branch_main(&cmdopt, c) } + Command::HashPassword(cmd) => { + println!("{}", portable::password_hash(&cmd.password)); + Ok(()) + } } } diff --git a/src/options.rs b/src/options.rs index 6de26e40..e9ac3384 100644 --- a/src/options.rs +++ b/src/options.rs @@ -373,6 +373,8 @@ pub enum Command { Watch(WatchCommand), /// Manage branches Branch(BranchCommand), + + HashPassword(HashPasswordCommand), } #[derive(clap::Args, Clone, Debug)] @@ -430,6 +432,11 @@ pub struct Info { pub get: Option, } +#[derive(clap::Args, Clone, Debug)] +pub struct HashPasswordCommand { + pub password: String, +} + #[derive(Debug, Clone)] pub struct Options { pub app: clap::Command, diff --git a/src/portable/mod.rs b/src/portable/mod.rs index a9227938..c532b1c1 100644 --- a/src/portable/mod.rs +++ b/src/portable/mod.rs @@ -28,3 +28,4 @@ mod uninstall; mod upgrade; pub use main::{instance_main, project_main, server_main}; +pub use reset_password::password_hash; diff --git a/tests/func/non_interactive.rs b/tests/func/non_interactive.rs index 611cb584..69150139 100644 --- a/tests/func/non_interactive.rs +++ b/tests/func/non_interactive.rs @@ -240,3 +240,14 @@ fn branch_commands() { // TODO: test how this works in projects } + +#[test] +fn hash_password() { + crate::edgedb_cli_cmd() + .arg("hash-password") + .arg("password1234") + .assert() + .context("hash-password", "basic usage") + .success() + .stdout(predicates::str::starts_with("SCRAM-SHA-256$")); +}