GithubHelp home page GithubHelp logo

travist / clicpp Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 0.0 96 KB

This is a helper class to assist with creating command line applications in C++ where you can easily gather settings for your application.

C++ 100.00%

clicpp's Introduction

CLICPP

This is a helper class for easily collecting and storing settings for your C++ command line application.

The CLICPP class accepts parameters in 3 different ways.

User Input

With this method, you can allow your application to ask the user for the parameters for your application within the terminal.

Cached User Input

This method allows you to cache previous inputs from the user so that when they run the application again, they do not have to re-enter previous settings.

Command Line Arguments

You can also pass arguments directly into this class so that you can run your application using the following syntax.

myapplication -first "Travis" -middle "Michael" -last "Tidwell"

Example

The following is an example of how you can use this library in your C++ application.

#include <stdio.h>
#include <iostream.h>
#include <cstdlib>
#include "clicpp.h";

// Using the std namespace.
using namespace std;

int main(int argc, char** argv) {

  // Initialize the clicpp variable.
  CLICPP cli(argc, argv);

  // Ask for first and last name and cache them.
  string first = cli.get("first", "What is your first name?", true);
  string last = cli.get("last", "What is your last name?", true);

  // Ask for a password, don't cache, and don't show in the terminal.
  string pass = cli.get("pass", "What is your password?", false, true);

  // Ask for something and don't cache it.
  string param = cli.get("param", "Type something... anything...");

  cout << "Your first name: " << first.c_str() << endl;
  cout << "Your last name: " << last.c_str() << endl;
  cout << "You typed: " << param.c_str() << endl;
  return 0;
}

clicpp's People

Contributors

travist avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  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.