Skip to content

Commit e6a485c

Browse files
authored
Use subcommands instead of flag style (#237)
Also update banner for readability
1 parent 974b03b commit e6a485c

File tree

5 files changed

+38
-48
lines changed

5 files changed

+38
-48
lines changed

server/src/banner.rs

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,14 @@
1818
*/
1919

2020
use crossterm::style::Stylize;
21-
use sysinfo::{System, SystemExt};
2221

23-
use crate::{option::Config, utils::capitalize_ascii};
22+
use crate::option::Config;
2423

2524
pub fn print(config: &Config) {
2625
let scheme = config.parseable.get_scheme();
2726
status_info(config, &scheme);
28-
version::print();
2927
storage_info(config);
30-
system_info();
28+
version::print();
3129
println!();
3230
}
3331

@@ -57,31 +55,16 @@ fn storage_info(config: &Config) {
5755
eprintln!(
5856
"
5957
{}
60-
Local Staging Path: {}
61-
{} Storage: {}",
58+
Mode: {}
59+
Staging path: {}
60+
Store path: {}",
6261
"Storage:".to_string().blue().bold(),
62+
config.storage_name,
6363
config.staging_dir().to_string_lossy(),
64-
capitalize_ascii(config.storage_name),
6564
config.storage().get_endpoint(),
6665
)
6766
}
6867

69-
pub fn system_info() {
70-
let system = System::new_all();
71-
eprintln!(
72-
"
73-
{}
74-
OS: {}
75-
Processor: {} logical, {} physical
76-
Memory: {:.2} GiB total",
77-
"System:".to_string().blue().bold(),
78-
os_info::get(),
79-
num_cpus::get(),
80-
num_cpus::get_physical(),
81-
system.total_memory() as f32 / (1024 * 1024 * 1024) as f32
82-
)
83-
}
84-
8568
pub fn warning_line() {
8669
eprint!(
8770
"
@@ -112,24 +95,34 @@ pub mod version {
11295
}
11396
}
11497

98+
pub fn print_version(current_version: semver::Version, commit_hash: String) {
99+
eprint!(
100+
"
101+
{}
102+
Version: {}
103+
Commit hash: {}
104+
GitHub: https://github.com/parseablehq/parseable
105+
Docs: https://www.parseable.io/docs/introduction",
106+
"About:".to_string().blue().bold(),
107+
current_version,
108+
commit_hash
109+
);
110+
}
111+
115112
pub fn print() {
116113
// print current version
117114
let current = current();
118115

119116
match current.0 {
120117
ParseableVersion::Version(current_version) => {
121-
// not eprintln because if it is old release then time passed with be displayed beside it
122-
eprint!(
123-
"
124-
{} {} ",
125-
"Current Version:".to_string().blue().bold(),
126-
current_version
127-
);
128-
129-
// check for latest release
130-
let Ok(latest_release) = update::get_latest() else {
131-
eprintln!();
132-
return
118+
print_version(current_version.clone(), current.1);
119+
// check for latest release, if it cannot be fetched then print error as warn and return
120+
let latest_release = match update::get_latest() {
121+
Ok(latest_release) => latest_release,
122+
Err(e) => {
123+
log::warn!("{}", e);
124+
return;
125+
}
133126
};
134127

135128
if latest_release.version > current_version {

server/src/option.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl Config {
4343
let cli = parseable_cli_command().get_matches();
4444

4545
match cli.subcommand() {
46-
Some(("--local-store", m)) => {
46+
Some(("local-store", m)) => {
4747
let server = match Server::from_arg_matches(m) {
4848
Ok(server) => server,
4949
Err(err) => err.exit(),
@@ -68,7 +68,7 @@ impl Config {
6868
storage_name: "drive",
6969
}
7070
}
71-
Some(("--s3-store", m)) => {
71+
Some(("s3-store", m)) => {
7272
let server = match Server::from_arg_matches(m) {
7373
Ok(server) => server,
7474
Err(err) => err.exit(),
@@ -133,7 +133,7 @@ impl Default for Config {
133133
}
134134

135135
fn parseable_cli_command() -> Command {
136-
let local = Server::get_clap_command("--local-store");
136+
let local = Server::get_clap_command("local-store");
137137
let local = <FSConfig as Args>::augment_args_for_update(local);
138138

139139
let local = local
@@ -143,8 +143,7 @@ fn parseable_cli_command() -> Command {
143143
.mut_arg(Server::PASSWORD, |arg| {
144144
arg.required(false).default_value(Server::DEFAULT_PASSWORD)
145145
});
146-
147-
let s3 = Server::get_clap_command("--s3-store");
146+
let s3 = Server::get_clap_command("s3-store");
148147
let s3 = <S3Config as Args>::augment_args_for_update(s3);
149148

150149
command!()
@@ -155,14 +154,11 @@ fn parseable_cli_command() -> Command {
155154
.next_line_help(false)
156155
.help_template(
157156
r#"
158-
{name} - v{version}
159-
{about-with-newline}
157+
{about} Join the community at https://launchpass.com/parseable.
158+
160159
{all-args}
161-
{after-help}
162-
{author}
163160
"#,
164161
)
165-
.after_help("Checkout https://parseable.io for documentation")
166162
.subcommand_required(true)
167163
.subcommands([local, s3])
168164
}
@@ -296,7 +292,7 @@ impl Server {
296292
.value_name("SECONDS")
297293
.default_value("60")
298294
.value_parser(value_parser!(u64))
299-
.help("Interval in seconds after which uncommited data would be uploaded to the storage platform.")
295+
.help("Interval in seconds after which un-committed data would be sent to the storage")
300296
.next_line_help(true),
301297
)
302298
.arg(

server/src/storage/localfs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use super::{LogStream, ObjectStorage, ObjectStorageError, ObjectStorageProvider}
4343
#[derive(Debug, Clone, clap::Args)]
4444
#[command(
4545
name = "Local filesystem config",
46-
about = "Start Parseable with local filesystem as storage backend (non production use only)",
46+
about = "Start Parseable with a drive as storage",
4747
help_template = "\
4848
{about-section}
4949
{all-args}

server/src/storage/s3.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ use super::ObjectStorageProvider;
5353
#[derive(Debug, Clone, clap::Args)]
5454
#[command(
5555
name = "S3 config",
56-
about = "Start Parseable with AWS S3 or compatible as storage backend",
56+
about = "Start Parseable with S3 or compatible as storage",
5757
help_template = "\
5858
{about-section}
5959
{all-args}

server/src/utils.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ pub fn hostname_unchecked() -> String {
117117
hostname::get().unwrap().into_string().unwrap()
118118
}
119119

120+
#[allow(dead_code)]
120121
pub fn capitalize_ascii(s: &str) -> String {
121122
s[0..1].to_uppercase() + &s[1..]
122123
}

0 commit comments

Comments
 (0)