Moved Command enum to the commands module

This commit is contained in:
StNicolay 2023-05-28 01:42:06 +03:00
parent c3af1144db
commit 1989283754
Signed by: StNicolay
GPG Key ID: 9693D04DCD962B0D
2 changed files with 34 additions and 33 deletions

View File

@ -27,3 +27,36 @@ pub use help::help;
pub use import::import;
pub use set_master_pass::set_master_pass;
pub use start::start;
use teloxide::macros::BotCommands;
#[derive(BotCommands, Clone, Copy)]
#[command(
rename_rule = "snake_case",
description = "These commands are supported:"
)]
pub enum Command {
#[command(description = "displays the welcome message")]
Start,
#[command(description = "displays this text")]
Help,
#[command(description = "sets the master password")]
SetMasterPass,
#[command(description = "adds the account")]
AddAccount,
#[command(description = "gets the account")]
GetAccount,
#[command(description = "gets a list of accounts")]
GetAccounts,
#[command(description = "deletes the account")]
Delete,
#[command(description = "deletes all the accounts and the master password")]
DeleteAll,
#[command(description = "exports all the accounts in a json file")]
Export,
#[command(description = "loads the accounts from a json file")]
Import,
#[command(description = "generates 10 secure passwords")]
GenPassword,
#[command(description = "cancels the current action")]
Cancel,
}

View File

@ -5,6 +5,7 @@ mod master_password_check;
mod state;
mod utils;
use commands::Command;
use sea_orm::prelude::*;
use state::{Handler, PackagedHandler};
use teloxide::{
@ -12,43 +13,10 @@ use teloxide::{
dispatching::dialogue::InMemStorage,
filter_command,
prelude::*,
utils::command::BotCommands,
};
type MainDialogue = Dialogue<State, InMemStorage<State>>;
#[derive(BotCommands, Clone, Copy)]
#[command(
rename_rule = "snake_case",
description = "These commands are supported:"
)]
enum Command {
#[command(description = "displays the welcome message")]
Start,
#[command(description = "displays this text")]
Help,
#[command(description = "sets the master password")]
SetMasterPass,
#[command(description = "adds the account")]
AddAccount,
#[command(description = "gets the account")]
GetAccount,
#[command(description = "gets a list of accounts")]
GetAccounts,
#[command(description = "deletes the account")]
Delete,
#[command(description = "deletes all the accounts and the master password")]
DeleteAll,
#[command(description = "exports all the accounts in a json file")]
Export,
#[command(description = "loads the accounts from a json file")]
Import,
#[command(description = "generates 10 secure passwords")]
GenPassword,
#[command(description = "cancels the current action")]
Cancel,
}
#[derive(Default, Clone)]
pub enum State {
#[default]