diff --git a/setup.ion b/setup.ion old mode 100644 new mode 100755 index 67525411ef5a863b0b3e0b7f54eb4f4e8cbb1521..0946c425e1ed1ce2f4cc0c25da4a893c73a2361d --- a/setup.ion +++ b/setup.ion @@ -74,7 +74,7 @@ match "@args[1..3]" sudo install target/release/ion ${DESTDIR}/ion case "install docs" echo "${c::0xF30,bold}Installing documentation with root${c::reset}" - sudo mkdir ${SHAREDIR}/docs/ -p + sudo mkdir -p ${SHAREDIR}/docs/ sudo cp manual/book/* ${SHAREDIR}/docs/ -R case "install plugins" git clone https://github.com/mmstick/ion-plugins diff --git a/src/shell/binary/mod.rs b/src/shell/binary/mod.rs index 0789a0b5903729c6158298f33aa38c4f073e5577..a007738eb88fe906202862d8e0349f3acb9b0299 100644 --- a/src/shell/binary/mod.rs +++ b/src/shell/binary/mod.rs @@ -19,6 +19,29 @@ use std::io::ErrorKind; use std::iter::{self, FromIterator}; use std::path::Path; use std::process; +use std::io::{stdout, Write}; +use std::error::Error; + +const MAN_ION: &'static str = r#"NAME + ion - ion shell + +SYNOPSIS + ion [ -h | --help ] [-c] [-n] [-v] + +DESCRIPTION + ion is a commandline shell created to be a faster and easier to use alternative to the + currently available shells. It is not POSIX compliant. + +OPTIONS + -c + evaulates given commands instead of reading from the commandline. + + -n or --no-execute + do not execute any commands, just do syntax checking. + + -v or --version + prints the version, platform and revision of ion then exits. +"#; pub(crate) trait Binary { /// Launches the shell, parses arguments, and then diverges into one of the `execution` @@ -175,15 +198,22 @@ impl Binary for Shell { let mut args = env::args().skip(1); while let Some(path) = args.next() { match path.as_str() { - "-n" => { + "-n" | "--no-execute" => { self.flags |= NO_EXEC; continue; } "-c" => self.execute_arguments(args), - "--version" => self.display_version(), + "-v" | "--version" => self.display_version(), "-h" | "--help" => { - println!("usage: ion [--version] [-c] [-n] <command>"); - return; + let stdout = stdout(); + let mut stdout = stdout.lock(); + match stdout + .write_all(MAN_ION.as_bytes()) + .and_then(|_| stdout.flush()) + { + Ok(_) => return, + Err(err) => panic!("{}", err.description().to_owned()), + } } _ => { let mut array = SmallVec::from_iter(Some(path.clone().into()));