Skip to content

Commit

Permalink
[2.1.6] Make it possible to not display the banner.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew121410 committed Nov 14, 2024
1 parent 62f6e44 commit 50521f9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "limonium"
version = "2.1.5"
version = "2.1.6"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
1. --help `Shows the help menu`
2. --version `Shows the version of Limonium`
3. --self-update `Updates limonium if there is a new version available`
4. --nb `Doesn't show the banner when running the program`

## Download Function
Download function uses platform specific download APIs(Paper, Purpur) or Jenkins(Pufferfish) to download the software.
Expand Down
42 changes: 32 additions & 10 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ extern crate serde;
extern crate serde_derive;
extern crate serde_json;

use crate::backup::BackupFormat;
use crate::log_search::LogSearch;
use crate::objects::DownloadedJar::DownloadedJar;
use clap::builder::TypedValueParser;
use clap::{ArgAction, ArgMatches};
use colored::Colorize;
Expand All @@ -15,10 +18,6 @@ use std::path::{Path, PathBuf};
use std::string::String;
use std::time::Instant;
use std::{env, fs, process};
use std::fmt::format;
use crate::backup::BackupFormat;
use crate::log_search::LogSearch;
use crate::objects::DownloadedJar::DownloadedJar;

mod backup;
mod clap_utils;
Expand All @@ -40,13 +39,17 @@ fn show_example() {
);
}

fn print_console_box() {
fn print_banner() {
let title = "Limonium";
let subtitle = "A tiny Minecraft Server management tool";
let version = format!("Version: {}", cargo_crate_version!());
let developer = "Developed by Andrew121410!";

// Determine the width of the box based on the longest line
let width = usize::max(title.len(), usize::max(subtitle.len(), version.len())) + 4;
let width = usize::max(
title.len(),
usize::max(subtitle.len(), usize::max(version.len(), developer.len())),
) + 4; // Adding padding for border

// Border
let border = "*".repeat(width);
Expand Down Expand Up @@ -82,15 +85,21 @@ fn print_console_box() {
" ".repeat((width - version.len() - 2) / 2)
)
);
println!("*{}*", " ".repeat(width - 2)); // Empty line
println!(
"*{}*",
format!(
"{}{}{}",
" ".repeat((width - developer.len() - 2) / 2),
developer.cyan(),
" ".repeat((width - developer.len() - 2) / 2)
)
);
println!("{}", border.green().bold());
}

#[tokio::main]
async fn main() {
print_console_box();
println!();
println!();

let matches_commands = clap::Command::new("limonium")
.version(cargo_crate_version!())
.author("Andrew121410")
Expand All @@ -103,6 +112,12 @@ async fn main() {
.global(true)
.action(ArgAction::SetTrue)
.required(false))
.arg(clap::Arg::new("no-banner")
.short('b')
.long("nb")
.aliases(["b"]) // --b
.help("Do not display the cool banner when program starts")
.action(ArgAction::SetTrue))
.subcommand(clap::Command::new("self-update")
.about("Updates Limonium"))
.subcommand(clap::Command::new("compile")
Expand Down Expand Up @@ -287,6 +302,13 @@ async fn main() {

let command_matches: ArgMatches = matches_commands.get_matches();

// Do not display the cool box if it's passed.
if !command_matches.get_flag("no-banner") {
print_banner();
println!();
println!();
}

// Handle self-update flag
if command_matches.get_flag("self-update") {
if self_update() {
Expand Down

0 comments on commit 50521f9

Please sign in to comment.