mirror of
https://github.com/soywod/himalaya.git
synced 2024-07-03 07:55:13 +00:00
fix default command
This commit is contained in:
parent
0352e91e36
commit
70fad9b1fd
|
@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
### Fixed
|
||||
|
||||
- Fixed default command: running `himalaya` without argument will list envelopes, as it used to be in previous versions.
|
||||
- Fixed bug when listing envelopes with `backend = "imap"`, `sync.enable = true` and `envelope.watch.backend = "imap"` led to unwanted IMAP connection creation (which slowed down the listing).
|
||||
|
||||
## [1.0.0-beta] - 2024-01-01
|
||||
|
|
|
@ -23,7 +23,7 @@ use crate::{
|
|||
#[command(propagate_version = true, infer_subcommands = true)]
|
||||
pub struct Cli {
|
||||
#[command(subcommand)]
|
||||
pub command: HimalayaCommand,
|
||||
pub command: Option<HimalayaCommand>,
|
||||
|
||||
/// Override the default configuration file path
|
||||
///
|
||||
|
|
|
@ -50,6 +50,19 @@ pub struct ListEnvelopesCommand {
|
|||
pub account: AccountNameFlag,
|
||||
}
|
||||
|
||||
impl Default for ListEnvelopesCommand {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
folder: Default::default(),
|
||||
page: 1,
|
||||
page_size: Default::default(),
|
||||
table: Default::default(),
|
||||
cache: Default::default(),
|
||||
account: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ListEnvelopesCommand {
|
||||
pub async fn execute(self, printer: &mut impl Printer, config: &TomlConfig) -> Result<()> {
|
||||
info!("executing list envelopes command");
|
||||
|
|
|
@ -18,6 +18,14 @@ pub struct FolderNameOptionalArg {
|
|||
pub name: String,
|
||||
}
|
||||
|
||||
impl Default for FolderNameOptionalArg {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
name: INBOX.to_owned(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The required folder name argument parser.
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct FolderNameArg {
|
||||
|
|
16
src/main.rs
16
src/main.rs
|
@ -2,8 +2,8 @@ use anyhow::Result;
|
|||
use clap::Parser;
|
||||
use env_logger::{Builder as LoggerBuilder, Env, DEFAULT_FILTER_ENV};
|
||||
use himalaya::{
|
||||
cli::Cli, config::TomlConfig, message::command::mailto::MessageMailtoCommand,
|
||||
printer::StdoutPrinter,
|
||||
cli::Cli, config::TomlConfig, envelope::command::list::ListEnvelopesCommand,
|
||||
message::command::mailto::MessageMailtoCommand, printer::StdoutPrinter,
|
||||
};
|
||||
use log::{debug, warn};
|
||||
use std::env;
|
||||
|
@ -35,7 +35,13 @@ async fn main() -> Result<()> {
|
|||
let cli = Cli::parse();
|
||||
let mut printer = StdoutPrinter::new(cli.output, cli.color);
|
||||
|
||||
cli.command
|
||||
.execute(&mut printer, cli.config_path.as_ref())
|
||||
.await
|
||||
match cli.command {
|
||||
Some(cmd) => cmd.execute(&mut printer, cli.config_path.as_ref()).await,
|
||||
None => {
|
||||
let config = TomlConfig::from_some_path_or_default(cli.config_path.as_ref()).await?;
|
||||
ListEnvelopesCommand::default()
|
||||
.execute(&mut printer, &config)
|
||||
.await
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use clap::Parser;
|
||||
|
||||
/// The table max width argument parser.
|
||||
#[derive(Debug, Parser)]
|
||||
#[derive(Debug, Default, Parser)]
|
||||
pub struct TableMaxWidthFlag {
|
||||
/// The maximum width the table should not exceed.
|
||||
///
|
||||
|
|
Loading…
Reference in a new issue