Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 28 additions & 35 deletions server/src/banner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@
*/

use crossterm::style::Stylize;
use sysinfo::{System, SystemExt};

use crate::{option::Config, utils::capitalize_ascii};
use crate::option::Config;

pub fn print(config: &Config) {
let scheme = config.parseable.get_scheme();
status_info(config, &scheme);
version::print();
storage_info(config);
system_info();
version::print();
println!();
}

Expand Down Expand Up @@ -57,31 +55,16 @@ fn storage_info(config: &Config) {
eprintln!(
"
{}
Local Staging Path: {}
{} Storage: {}",
Mode: {}
Staging path: {}
Store path: {}",
"Storage:".to_string().blue().bold(),
config.storage_name,
config.staging_dir().to_string_lossy(),
capitalize_ascii(config.storage_name),
config.storage().get_endpoint(),
)
}

pub fn system_info() {
let system = System::new_all();
eprintln!(
"
{}
OS: {}
Processor: {} logical, {} physical
Memory: {:.2} GiB total",
"System:".to_string().blue().bold(),
os_info::get(),
num_cpus::get(),
num_cpus::get_physical(),
system.total_memory() as f32 / (1024 * 1024 * 1024) as f32
)
}

pub fn warning_line() {
eprint!(
"
Expand Down Expand Up @@ -112,24 +95,34 @@ pub mod version {
}
}

pub fn print_version(current_version: semver::Version, commit_hash: String) {
eprint!(
"
{}
Version: {}
Commit hash: {}
GitHub: https://github.com/parseablehq/parseable
Docs: https://www.parseable.io/docs/introduction",
"About:".to_string().blue().bold(),
current_version,
commit_hash
);
}

pub fn print() {
// print current version
let current = current();

match current.0 {
ParseableVersion::Version(current_version) => {
// not eprintln because if it is old release then time passed with be displayed beside it
eprint!(
"
{} {} ",
"Current Version:".to_string().blue().bold(),
current_version
);

// check for latest release
let Ok(latest_release) = update::get_latest() else {
eprintln!();
return
print_version(current_version.clone(), current.1);
// check for latest release, if it cannot be fetched then print error as warn and return
let latest_release = match update::get_latest() {
Ok(latest_release) => latest_release,
Err(e) => {
log::warn!("{}", e);
return;
}
};

if latest_release.version > current_version {
Expand Down
18 changes: 7 additions & 11 deletions server/src/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl Config {
let cli = parseable_cli_command().get_matches();

match cli.subcommand() {
Some(("--local-store", m)) => {
Some(("local-store", m)) => {
let server = match Server::from_arg_matches(m) {
Ok(server) => server,
Err(err) => err.exit(),
Expand All @@ -68,7 +68,7 @@ impl Config {
storage_name: "drive",
}
}
Some(("--s3-store", m)) => {
Some(("s3-store", m)) => {
let server = match Server::from_arg_matches(m) {
Ok(server) => server,
Err(err) => err.exit(),
Expand Down Expand Up @@ -133,7 +133,7 @@ impl Default for Config {
}

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

let local = local
Expand All @@ -143,8 +143,7 @@ fn parseable_cli_command() -> Command {
.mut_arg(Server::PASSWORD, |arg| {
arg.required(false).default_value(Server::DEFAULT_PASSWORD)
});

let s3 = Server::get_clap_command("--s3-store");
let s3 = Server::get_clap_command("s3-store");
let s3 = <S3Config as Args>::augment_args_for_update(s3);

command!()
Expand All @@ -155,14 +154,11 @@ fn parseable_cli_command() -> Command {
.next_line_help(false)
.help_template(
r#"
{name} - v{version}
{about-with-newline}
{about} Join the community at https://launchpass.com/parseable.

{all-args}
{after-help}
{author}
"#,
)
.after_help("Checkout https://parseable.io for documentation")
.subcommand_required(true)
.subcommands([local, s3])
}
Expand Down Expand Up @@ -296,7 +292,7 @@ impl Server {
.value_name("SECONDS")
.default_value("60")
.value_parser(value_parser!(u64))
.help("Interval in seconds after which uncommited data would be uploaded to the storage platform.")
.help("Interval in seconds after which un-committed data would be sent to the storage")
.next_line_help(true),
)
.arg(
Expand Down
2 changes: 1 addition & 1 deletion server/src/storage/localfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use super::{LogStream, ObjectStorage, ObjectStorageError, ObjectStorageProvider}
#[derive(Debug, Clone, clap::Args)]
#[command(
name = "Local filesystem config",
about = "Start Parseable with local filesystem as storage backend (non production use only)",
about = "Start Parseable with a drive as storage",
help_template = "\
{about-section}
{all-args}
Expand Down
2 changes: 1 addition & 1 deletion server/src/storage/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ use super::ObjectStorageProvider;
#[derive(Debug, Clone, clap::Args)]
#[command(
name = "S3 config",
about = "Start Parseable with AWS S3 or compatible as storage backend",
about = "Start Parseable with S3 or compatible as storage",
help_template = "\
{about-section}
{all-args}
Expand Down
1 change: 1 addition & 0 deletions server/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ pub fn hostname_unchecked() -> String {
hostname::get().unwrap().into_string().unwrap()
}

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