Java command line program build tool-airline

Source: Internet
Author: User

Java command line program build tool-airline

In the past, I used to develop Java command line programs. I had a lot of trouble parsing parameters and some help information, today, when studying the interface test, I accidentally discovered a tool that allows you to quickly build a command line program.

Github address

Airline

Import jar package

Airline jar
Search for statements suitable for your system building in the maven Repository

Code

I found an explanation.harFile project to explain the development process

Customize your own command line

My command line usesdoctorqAs a command, the parameter iscompanyThe complete command format should bedoctorq company XXXXX.

@ Command (name = "doctorq", description = "test for cli") public class Doctorq implements Runnable {@ Arguments private String company;/* (non-Javadoc) * @ see java. lang. runnable # run () */@ Override public void run () {// TODO Auto-generated method stub System. out. println ("Doctorq belongs to" + company );}}
mainFunction
public class HarCli {    public static void main(String[] args) {        @SuppressWarnings("unchecked")        CliBuilder
  
    builder = Cli.
   
    builder("har")                                          .withDescription("HAR power tool")                                          .withDefaultCommand(Help.class)                                          .withCommands(Help.class, Doctorq.class);        Cli
    
      cliParser = builder.build();        try {                cliParser.parse(args).run();        } catch(ParseArgumentsUnexpectedException e) {                System.out.println("Invalid command, use '$ har help' for usage instructions!");        }    }}
    
   
  
Run

I am using a maven project. For the configuration, see how to package the maven project into an executable jar file.

Eclipse

PointRunThe following information is output:

Jar package execution

First package:mvn packageAfter execution, a jar package is generated under the target directory of the root directory.

Go to the target package and run the following command: <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4NCjxwPjxpbWcgYWx0PQ = "here write picture description" src = "http://www.bkjia.com/uploads/allimg/160122/04230440L-3.png" title = ""/>

Related Article

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.