cmdline-extension Golang Std.flag

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Based on the Golang 1.6.2 flag source has made an extension
Make command-line help information more complete, clearer, and easier to use
Source Address: Http://github.com/vipally/cmdline

Ally (vipally@gmail.com) modify from Std.flag version 1.6.2
1. Add Logicname and Required field for every flag, and modify the flag define interface
2. Add Summary and Details for Commond line info
3. Add interface Getusage () string
4. Modify the Parse () logic

Func Main () {cmdline. Summary ("command copy is used-to-copy a file to another path.") CmdLine. Details (' Command copy is used toCopya file  toAnother path. If theDestnationfileis exist, default ask for ifwould coverit. If Flag-y used,itwould cover theDestnationfile withoutAsk. If Flag-n used,itWould notCover theDestnationfile withoutAsk. ') cmdline. String ("S","src",".",true,"source file path") CmdLine. String ("D","DST",".",true,"destnation file path") CmdLine. Bool ("C","Cover",false,false,"If cover the Destnation file") CmdLine. Bool ("Y","Yes",false,false,"If Auto Select Yes when ask for cover") CmdLine. Bool ("n","No",false,false,"If auto Select No when ask for cover") CmdLine. Parse ()//[error] require but lack of flag-s=<src>   //usage of [Copy.exe]:   //Summary:   //Command copy is used-to-copy a file to another path    //   //Usage:   //Copy.exe [-c=<cover>]-d=<dst> [-n=<no>]-s=<src> [-y=<yes>]   //-c=<cover>   //If cover the Destnation file   //-d=<dst> Required String (default ".")   //destnation file path   //-n=<no> If auto Select No when ask for cover   //-s=<src> Required String (default ".")   //source file path   //-y=<yes>   //If auto Select Yes when ask for cover    //   //Details:   //Command copy is used to copy a, file to another path.   //If the Destnation file is exist and default ask for If would cover it.   //If flag-y used, it'll cover the destnation file without ask.   //If flag-n used, it'll not cover the destnation file without ask.}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.