Giter Club home page Giter Club logo

airline's Introduction

airline


https://github.com/airlift/airline

public class Git
{
  public static void main(String[] args)
  {
    CliBuilder<Runnable> builder = Cli.<Runnable>builder("git")
      .withDescription("the stupid content tracker")
      .withDefaultCommand(Help.class)
      .withCommands(Help.class, Add.class);
    
    builder.withGroup("remote")
      .withDescription("Manage set of tracked repositories")
      .withDefaultCommand(RemoteShow.class)
      .withCommands(RemoteShow.class, RemoteaAdd.class);
      
    Cli<Runnable> gitParser = builder.builder();
    
    gitParser.parse(args).run();
  }
  
  public static class GitCommand implements Runnable
  {
    @Option(type = OptionType.GLOBAL, name = "-v", description = "Verbose mode")
    public boolean verbose;
    
    public void run()
    {
      System.out.println(getClass().getSimpleName());
    }
  }
  
  @Command(name = "add", description = "Add file contents to the index")
  public static class Add extends GitCommand
  {
    @Arguments(description = "Patterns of files to be added")
    public List<String> patterns;
    
    @Option(name = "-i", description = "Add modified contents interactively.")
    public boolean interactive;
  }
  
  @Command(name = "show", description = "Gives some information about the remote <name>")
  public static class RemoteShow extends GitCommand
  {
    @Arguments(description = "Do not query remote heads")
    public boolean noQuery;
    
    @Arguments(description = "Remote to show")
    public String remote;
  }
  
  @Command(name = "add", description = "Adds a remote")
  public static class RemoteAdd extends GitCommand
  {
    @Option(name = "-t", description = "Track only a specific branch")
    public String branch;
    
    @Arguments(description = "Remote repository to add")
    public List<String> remote;
  }
}

@Command(name = "ping", description = "network test utility")
public class Ping
{
  @Inject
  public HelpOption helpOption;
  
  @Option(name = {"-c", "--count"}, description = "Send count packets")
  public int count = 1;
  
  public static void main(String... args)
  {
    Ping ping = SingleCommand.singleCommand(Ping.class).parse(args);
    
    if (ping.helpOption.showHelpIfRequested()) {
      return;
    }
    
    ping.run();
  }
  
  public void run()
  {
    System.out.println("Ping count: " + count);
  }
}
ping
ping -c 5
ping --help
ping -h

airline's People

Contributors

takagotch avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.