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)
|
## [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)
|
## [0.2.1](https://git.rustybever.be/Chewing_Bever/otter/src/tag/0.2.1)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use clap::Subcommand;
|
use clap::{Args, Subcommand};
|
||||||
|
|
||||||
use super::CliError;
|
use super::CliError;
|
||||||
|
|
||||||
|
@ -11,6 +11,14 @@ pub enum Command {
|
||||||
},
|
},
|
||||||
/// List the devices for the given user
|
/// List the devices for the given user
|
||||||
Devices { username: String },
|
Devices { username: String },
|
||||||
|
|
||||||
|
#[command(subcommand)]
|
||||||
|
User(UserCommand),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Subcommand)]
|
||||||
|
pub enum UserCommand {
|
||||||
|
Add { username: String, password: String },
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Command {
|
impl Command {
|
||||||
|
@ -36,6 +44,21 @@ impl Command {
|
||||||
println!("{} ({} subscriptions)", device.id, device.subscriptions);
|
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(())
|
Ok(())
|
||||||
|
|
|
@ -6,7 +6,9 @@
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for user in users %}
|
{% for user in users %}
|
||||||
|
<tr>
|
||||||
<th>{{ user.username }}</th>
|
<th>{{ user.username }}</th>
|
||||||
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{%- if next_page_query %}
|
{%- if next_page_query %}
|
||||||
|
|
Loading…
Reference in New Issue