Skip to content

Commit

Permalink
Show version on GUI and terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
martinber committed Aug 26, 2018
1 parent b1f5822 commit 5139a15
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "noaa-apt"
version = "0.9.1"
version = "0.9.4"
authors = ["Martin Bernardi <[email protected]>"]

[dependencies]
Expand Down
11 changes: 11 additions & 0 deletions src/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ use gio::prelude::*;
use gtk::prelude::*;
use gtk::Builder;

const VERSION: &'static str = env!("CARGO_PKG_VERSION");

// make moving clones into closures more convenient
macro_rules! clone {
(@param _) => ( _ );
Expand Down Expand Up @@ -66,6 +68,15 @@ fn build_ui(application: &gtk::Application) {
status_label.set_label("Ready");
start_button.set_sensitive(true);

// Set version on footer

let footer_label: gtk::Label = builder.get_object("footer_label")
.expect("Couldn't get footer_label");
footer_label.set_label(format!(
"noaa-apt {}
Martín Bernardi
[email protected]", VERSION).as_str());

// Configure decode_output_entry file chooser

let decode_output_entry: gtk::Entry = builder.get_object("decode_output_entry")
Expand Down
13 changes: 13 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ mod misc;
mod gui;
mod err;

const VERSION: &'static str = env!("CARGO_PKG_VERSION");

fn main() -> err::Result<()> {

let mut input_filename: Option<String> = None;
let mut debug = false;
let mut quiet = false;
let mut print_version = false;
let mut output_filename: Option<String> = None;
let mut resample_output: Option<u32> = None;
{
Expand All @@ -30,6 +33,9 @@ fn main() -> err::Result<()> {
parser.refer(&mut input_filename)
.add_argument("input_filename", argparse::StoreOption,
"Input WAV file.");
parser.refer(&mut print_version)
.add_option(&["-v", "--version"], argparse::StoreTrue,
"Show version and quit.");
parser.refer(&mut debug)
.add_option(&["-d", "--debug"], argparse::StoreTrue,
"Print debugging messages.");
Expand All @@ -49,6 +55,11 @@ fn main() -> err::Result<()> {
parser.parse_args_or_exit();
}

if print_version {
println!("noaa-apt image decoder version {}", VERSION);
std::process::exit(0);
}

if debug {
simple_logger::init_with_level(log::Level::Debug)?;
} else if quiet {
Expand All @@ -57,6 +68,8 @@ fn main() -> err::Result<()> {
simple_logger::init_with_level(log::Level::Info)?;
}

info!("noaa-apt image decoder version {}", VERSION);

match input_filename {

// Input filename set, command line
Expand Down

0 comments on commit 5139a15

Please sign in to comment.