feat: sort config outputs
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
use std::cmp::Ordering;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use clap::Args;
|
use clap::Args;
|
||||||
@@ -8,12 +9,24 @@ use tabled::settings::Style;
|
|||||||
use crate::config::TinyEncryptConfig;
|
use crate::config::TinyEncryptConfig;
|
||||||
use crate::util::TINY_ENC_CONFIG_FILE;
|
use crate::util::TINY_ENC_CONFIG_FILE;
|
||||||
|
|
||||||
#[derive(Tabled)]
|
#[derive(Tabled, Ord, Eq)]
|
||||||
struct ConfigProfile {
|
struct ConfigProfile {
|
||||||
profiles: String,
|
profiles: String,
|
||||||
keys: String,
|
keys: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PartialEq<Self> for ConfigProfile {
|
||||||
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
self.profiles.eq(&other.profiles)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialOrd for ConfigProfile {
|
||||||
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||||
|
self.profiles.partial_cmp(&other.profiles)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Args)]
|
#[derive(Debug, Args)]
|
||||||
pub struct CmdConfig {}
|
pub struct CmdConfig {}
|
||||||
|
|
||||||
@@ -57,6 +70,7 @@ pub fn config(_cmd_version: CmdConfig) -> XResult<()> {
|
|||||||
keys: ks.join("\n"),
|
keys: ks.join("\n"),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
config_profiles.sort();
|
||||||
|
|
||||||
let mut table = Table::new(config_profiles);
|
let mut table = Table::new(config_profiles);
|
||||||
table.with(Style::modern());
|
table.with(Style::modern());
|
||||||
|
|||||||
Reference in New Issue
Block a user