Git Product home page Git Product logo

command_helper's Introduction

Command Helper Library

A Delphi library that makes it easier to work with command line applications

Features

  • Auto parse command line arguments
  • Validation - Checks for duplicate commands and arguments and makes sure that required arguments have been provided
  • Cli app included to auto generate commands
  • Auto generate, format and display application help

  • Allows sub commands. The example below shows the "move" command and its two sub commands ("up" and "down")

Cli

You can build and use the cmdgen application to quickly generate commands

Usage

See the included demo application or follow along with the steps below

1) Build the cmdgen app

  • Open cmdgen.dproj and build the the cmdgen.exe app
  • Place the cmdgen.exe app in a directory in the Environment Variables "path"
  • Open a new terminal, run "cmdgen" and check the the app was found and execute

2) Create a new console application that uses uCommandHelper.pas

From within the Delphi IDE

  • Create a new Delphi console applications (File > New > Console Applications)
  • Right-click on the Project, click "Add", navigate to the "command_helper\src" folder and add uCommandHelper.pas
  • Create a TAppCommand and add code the execute it (see the "command_helper\demo\CommandHelperDemo.dpr" for an example)

3) Start adding commands to your application

  • Use the cmdgen.exe app to generate boilerplate command code. See an example below:
cd myapp\src
cmdgen g list

The sample code above will create a list_command.pas in the "myapp\src" directory

4) Link the newly generated command to your application

  • See "command_helper\demo\CommandHelperDemo.dpr" for an example
  • You could add the TListCommand with a line like below
  lAppCommand.commands.add(TListCommand.Create);

You can add an application description by assigning a description to the TAppCommand instance:

  lAppCommand.description := 'Sample app description';

That's it. Build your console application and run it without parameters. The application will automatically display application help

command_helper's People

Contributors

dhanekom avatar

Stargazers

球球 avatar Lübbe Onken avatar Edwin Yip avatar  avatar Charalampos Michael avatar  avatar

Watchers

Charalampos Michael avatar  avatar

command_helper's Issues

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.