diff --git a/CHANGELOG.md b/CHANGELOG.md index c1a273a..135063c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased](https://git.rustybever.be/Chewing_Bever/otter) +* CLI command to add new users + ## [0.2.1](https://git.rustybever.be/Chewing_Bever/otter/src/tag/0.2.1) ### Fixed diff --git a/otter/src/cli/gpo.rs b/otter/src/cli/gpo.rs index f2d0cf0..a0d72e5 100644 --- a/otter/src/cli/gpo.rs +++ b/otter/src/cli/gpo.rs @@ -1,4 +1,4 @@ -use clap::Subcommand; +use clap::{Args, Subcommand}; use super::CliError; @@ -11,6 +11,14 @@ pub enum Command { }, /// List the devices for the given user Devices { username: String }, + + #[command(subcommand)] + User(UserCommand), +} + +#[derive(Subcommand)] +pub enum UserCommand { + Add { username: String, password: String }, } impl Command { @@ -36,6 +44,21 @@ impl Command { println!("{} ({} subscriptions)", device.id, device.subscriptions); } } + Self::User(user) => { + user.run(&store)?; + } + } + + Ok(()) + } +} + +impl UserCommand { + pub fn run(&self, store: &gpodder::GpodderRepository) -> Result<(), CliError> { + match self { + Self::Add { username, password } => { + store.create_user(username, password)?; + } } Ok(()) diff --git a/otter/src/web/templates/views/users.html b/otter/src/web/templates/views/users.html index f53f815..22dee43 100644 --- a/otter/src/web/templates/views/users.html +++ b/otter/src/web/templates/views/users.html @@ -6,7 +6,9 @@
{% for user in users %} -