From 72640815b1ae0947840afb6a6d94e88d2cc38bd8 Mon Sep 17 00:00:00 2001 From: Wilfred Hughes Date: Fri, 27 Aug 2021 22:34:51 -0700 Subject: [PATCH] Use clap to extract package version from cargo --- src/main.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index a1e09917f..ea9d13b88 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,7 +11,7 @@ mod style; mod syntax; mod tree_sitter_parser; use atty::Stream; -use clap::{App, AppSettings, Arg}; +use clap::{crate_version, App, AppSettings, Arg}; use std::env; use std::ffi::OsStr; use std::path::Path; @@ -23,8 +23,6 @@ use crate::lines::{join_overlapping, visible_groups, MaxLine}; use crate::syntax::{change_positions, init_info, matching_lines}; use crate::tree_sitter_parser as tsp; -const VERSION: &str = env!("CARGO_PKG_VERSION"); - fn configure_color() { if atty::is(Stream::Stdout) || env::var("GIT_PAGER_IN_USE").is_ok() { // Always enable colour if stdout is a TTY or if the git pager is active. @@ -49,7 +47,7 @@ enum Mode { fn parse_args() -> Mode { let matches = App::new("Difftastic") - .version(VERSION) + .version(crate_version!()) .about("A syntax aware diff.") .author("Wilfred Hughes") .arg(Arg::with_name("dump-syntax").long("dump-syntax").help(