Skip to content

Commit

Permalink
Removal of lazy_static
Browse files Browse the repository at this point in the history
  • Loading branch information
a1ecbr0wn committed Oct 2, 2023
1 parent 5942a00 commit 4c169f1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ path = "src/main.rs"
name = "bookmark-cd"

[dependencies]
lazy_static = "1.4.0"
clap = { version = "4.4", features = ["derive"] }
csv = "1.2"
home = "0.5.5"
Expand Down
27 changes: 16 additions & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
use clap::Parser;
use csv::{Reader, Result, Writer};
use home::home_dir;
use lazy_static::lazy_static;
use std::env;
use std::path::Path;
use std::process::exit;
use std::{collections::BTreeMap, env::current_dir};
use std::{
collections::BTreeMap,
env,
env::current_dir,
path::Path,
process::exit,
sync::OnceLock,
};

use tabled::{
builder::Builder, settings::object::Segment, settings::Alignment, settings::Modify,
settings::Style,
Expand Down Expand Up @@ -34,12 +38,13 @@ fn main() {

let options = cli::Options::parse();

lazy_static! {
static ref DESCRIPTION: String = format!(
static DESCRIPTION: OnceLock<String> = OnceLock::new();
DESCRIPTION.get_or_init(|| {
format!(
"bcd {}: bookmark directories and move to them.",
env!("CARGO_PKG_VERSION")
);
};
)
});

if options.install {
// a way to try to set up the shell when the data file exists but the `bcd` function is not.
Expand All @@ -51,7 +56,7 @@ fn main() {
}

if options.version {
println!("{}", DESCRIPTION.as_str());
println!("{}", DESCRIPTION.get().unwrap().as_str());
exit(0);
}

Expand Down Expand Up @@ -158,7 +163,7 @@ fn main() {
exit(0);
}

println!("{}", DESCRIPTION.as_str());
println!("{}", DESCRIPTION.get().unwrap().as_str());
}
}

Expand Down

0 comments on commit 4c169f1

Please sign in to comment.