feat(otter): add command to create new users
parent
30609b1cef
commit
c7c5cf889c
|
@ -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
|
||||
|
|
|
@ -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(())
|
||||
|
|
|
@ -6,7 +6,9 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
{% for user in users %}
|
||||
<th>{{ user.username }}</th>
|
||||
<tr>
|
||||
<th>{{ user.username }}</th>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
{%- if next_page_query %}
|
||||
|
|
Loading…
Reference in New Issue