From 2f5e170bab335907277be052d98c0e97e7769817 Mon Sep 17 00:00:00 2001 From: Arthur Liao Date: Wed, 10 Dec 2014 20:46:33 +0800 Subject: [PATCH] Update sample code to use `getopts::usage` in `print_usage` --- src/libgetopts/lib.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/libgetopts/lib.rs b/src/libgetopts/lib.rs index 9174f8e8456..e2306bcadab 100644 --- a/src/libgetopts/lib.rs +++ b/src/libgetopts/lib.rs @@ -33,7 +33,7 @@ //! //! ```{.rust} //! extern crate getopts; -//! use getopts::{optopt,optflag,getopts,OptGroup}; +//! use getopts::{optopt,optflag,getopts,OptGroup,usage}; //! use std::os; //! //! fn do_work(inp: &str, out: Option) { @@ -44,10 +44,9 @@ //! } //! } //! -//! fn print_usage(program: &str, _opts: &[OptGroup]) { -//! println!("Usage: {} [options]", program); -//! println!("-o\t\tOutput"); -//! println!("-h --help\tUsage"); +//! fn print_usage(program: &str, opts: &[OptGroup]) { +//! let brief = format!("Usage: {} [options]", program); +//! print!("{}", usage(brief.as_slice(), opts)); //! } //! //! fn main() {