mirror of
https://github.com/soywod/himalaya.git
synced 2024-07-05 17:15:12 +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
|
||||||
|
|
||||||
|
- 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).
|
- 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
|
## [1.0.0-beta] - 2024-01-01
|
||||||
|
|
|
@ -23,7 +23,7 @@ use crate::{
|
||||||
#[command(propagate_version = true, infer_subcommands = true)]
|
#[command(propagate_version = true, infer_subcommands = true)]
|
||||||
pub struct Cli {
|
pub struct Cli {
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
pub command: HimalayaCommand,
|
pub command: Option<HimalayaCommand>,
|
||||||
|
|
||||||
/// Override the default configuration file path
|
/// Override the default configuration file path
|
||||||
///
|
///
|
||||||
|
|
|
@ -50,6 +50,19 @@ pub struct ListEnvelopesCommand {
|
||||||
pub account: AccountNameFlag,
|
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 {
|
impl ListEnvelopesCommand {
|
||||||
pub async fn execute(self, printer: &mut impl Printer, config: &TomlConfig) -> Result<()> {
|
pub async fn execute(self, printer: &mut impl Printer, config: &TomlConfig) -> Result<()> {
|
||||||
info!("executing list envelopes command");
|
info!("executing list envelopes command");
|
||||||
|
|
|
@ -18,6 +18,14 @@ pub struct FolderNameOptionalArg {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for FolderNameOptionalArg {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
name: INBOX.to_owned(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The required folder name argument parser.
|
/// The required folder name argument parser.
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
pub struct FolderNameArg {
|
pub struct FolderNameArg {
|
||||||
|
|
16
src/main.rs
16
src/main.rs
|
@ -2,8 +2,8 @@ use anyhow::Result;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use env_logger::{Builder as LoggerBuilder, Env, DEFAULT_FILTER_ENV};
|
use env_logger::{Builder as LoggerBuilder, Env, DEFAULT_FILTER_ENV};
|
||||||
use himalaya::{
|
use himalaya::{
|
||||||
cli::Cli, config::TomlConfig, message::command::mailto::MessageMailtoCommand,
|
cli::Cli, config::TomlConfig, envelope::command::list::ListEnvelopesCommand,
|
||||||
printer::StdoutPrinter,
|
message::command::mailto::MessageMailtoCommand, printer::StdoutPrinter,
|
||||||
};
|
};
|
||||||
use log::{debug, warn};
|
use log::{debug, warn};
|
||||||
use std::env;
|
use std::env;
|
||||||
|
@ -35,7 +35,13 @@ async fn main() -> Result<()> {
|
||||||
let cli = Cli::parse();
|
let cli = Cli::parse();
|
||||||
let mut printer = StdoutPrinter::new(cli.output, cli.color);
|
let mut printer = StdoutPrinter::new(cli.output, cli.color);
|
||||||
|
|
||||||
cli.command
|
match cli.command {
|
||||||
.execute(&mut printer, cli.config_path.as_ref())
|
Some(cmd) => cmd.execute(&mut printer, cli.config_path.as_ref()).await,
|
||||||
.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;
|
use clap::Parser;
|
||||||
|
|
||||||
/// The table max width argument parser.
|
/// The table max width argument parser.
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Default, Parser)]
|
||||||
pub struct TableMaxWidthFlag {
|
pub struct TableMaxWidthFlag {
|
||||||
/// The maximum width the table should not exceed.
|
/// The maximum width the table should not exceed.
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in a new issue