message: Calc man page
diff: use calculate::{eval, eval_polish, CalcError, Value};
  use std::io::{self, Write};
  +const REPL_GUIDE: &'static str = r#"ion-calc
  +Type in expressions to have them evaluated.
  +Type "help" for help."#;
  +
  +pub const MAN_CALC: &str = r#"NAME
  + calc - Floating point calculator
  +
  +SYNOPSIS
  + calc [EXPRESSION]
  +
  +DESCRIPTION
  + Evaluates arithmetic expressions
  +
  +SPECIAL EXPRESSIONS
  + help (only in interactive mode)
  + prints this help text
  +
  + --help (only in non-interactive mode)
  + prints this help text
  +
  + exit (only in interactive mode)
  + exits the program
  +
  +NOTATIONS
  + infix notation
  + e.g. 3 * 4 + 5
  +
  + polish notation
  + e.g. + * 3 4 5
  +
  +EXAMPLES
  + Add two plus two in infix notation
  + calc 2+2
  +
  + Add two plus two in polish notation
  + calc + 2 2
  +
  +AUTHOR
  + Written by Hunter Goldstein.
  +"#;
  +
  fn calc_or_polish_calc(args: &str) -> Result<Value, CalcError> {
  match eval(&args) {
  Ok(t) => Ok(t),
  @@ -11,14 +52,24 @@ fn calc_or_polish_calc(args: &str) -> Result<Value, CalcError> {
  pub fn calc(args: &[String]) -> Result<(), String> {
  let stdout = io::stdout();
  let mut stdout = stdout.lock();
  - if !args.is_empty() {
  + match args.first() {
  + Some(ref s) if (*s == "--help") => {
  + // "--help" only makes sense if it is the first option. Only look for it
  + // in the first position.
  + println!("{}", MAN_CALC);
  + Ok(())
  + }
  + Some(_) => {
  let result = calc_or_polish_calc(&args.join(" "));
  let _ = match result {
  Ok(v) => writeln!(stdout, "{}", v),
  Err(e) => writeln!(stdout, "{}", e),
  };
  - } else {
  + Ok(())
  + }
  + None => {
  let prompt = b"ion-calc: ";
  + println!("{}", REPL_GUIDE);
  loop {
  let _ = stdout.write(prompt);
  let _ = stdout.flush();
  @@ -30,6 +81,7 @@ pub fn calc(args: &[String]) -> Result<(), String> {
  match input.trim() {
  "" => (),
  "exit" => break,
  + "help" => println!("{}", MAN_CALC),
  s => {
  let result = calc_or_polish_calc(s);
  let _ = match result {
  @@ -40,6 +92,7 @@ pub fn calc(args: &[String]) -> Result<(), String> {
  }
  }
  }
  - }
  Ok(())
  }
  + }
  +}
  