From 9abdb438e36e364d41550e7f5d44ebcaa8ee6b10 Mon Sep 17 00:00:00 2001 From: Kevin K Date: Fri, 3 Apr 2015 11:02:46 -0400 Subject: [PATCH] fix(clap): remove unstable features for Rust 1.0 --- src/app.rs | 14 +++++++------- src/lib.rs | 4 ---- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/app.rs b/src/app.rs index 33109ea7..a8411eda 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1,5 +1,3 @@ -extern crate libc; - use std::collections::BTreeMap; use std::collections::HashMap; use std::collections::HashSet; @@ -7,6 +5,7 @@ use std::env; use std::path::Path; use std::vec::IntoIter; use std::borrow::ToOwned; +use std::process; use args::{ ArgMatches, Arg, SubCommand }; use args::{FlagArg, FlagBuilder}; @@ -619,7 +618,7 @@ impl<'a, 'v, 'ab, 'u, 'ar> App<'a, 'v, 'ab, 'u, 'ar>{ } } - self.exit(); + self.exit(0); } #[inline(always)] @@ -657,17 +656,18 @@ impl<'a, 'v, 'ab, 'u, 'ar> App<'a, 'v, 'ab, 'u, 'ar>{ // Print the binary name if existing, but replace all spaces with hyphens in case we're // dealing with subcommands i.e. git mv is translated to git-mv println!("{} {}", &self.bin_name.clone().unwrap_or(self.name.clone())[..].replace(" ", "-"), self.version.unwrap_or("") ); - if quit { self.exit(); } + if quit { self.exit(0); } } - fn exit(&self) { - unsafe { libc::exit(0); } + fn exit(&self, status: i32) { + process::exit(status); + // unsafe { libc::exit(0); } } fn report_error(&self, msg: String, usage: bool, quit: bool) { println!("{}", msg); if usage { self.print_usage(true); } - if quit { env::set_exit_status(1); self.exit(); } + if quit { self.exit(1); } } pub fn get_matches(mut self) -> ArgMatches<'ar> { diff --git a/src/lib.rs b/src/lib.rs index e8612d08..52bf03f2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,11 +1,7 @@ #![crate_type= "lib"] -#![feature(exit_status)] - // DOCS -extern crate libc; - pub use args::{Arg, SubCommand, ArgMatches}; pub use app::App;