Giter Club home page Giter Club logo

dli's Introduction

dli

dli is a command line interface library (I hope you appreciate the pun) for the D programming language. Although its main application lies in easing the fast development of cli apps, it can also be used in not-only-cli apps, such as in an embedded console in a GUI app.

This software is licensed under the MIT software license.

Why?

Because I hate handling user input every single time I need to ask for data, in every single app I write.

Highlighted features

  • Safely and easily request data from your user with the templated request method:
    /* This code will keep asking for data until an integer
       number that fits in an `int` and satisfies the given
       condition is given */
    import dli;

    int myEvenInt;
	while(!request("Please, input an even integer: ", &myEvenInt,
                   (int myInt){return myInt % 2 == 0;})) // This argument is optional!
        writeln("That is not an even integer.");

The library also optionally supports the evaluation of math expressions for numeric types. So, if you ask for an int, 128 * 5 / 2 is a perfectly valid input. The wiki contains more information regarding math expression support.

  • Easily create and run key-based menus:
    import dli;

    auto mainMenu = createIndexMenu();
    mainMenu.welcomeMsg = "Please choose an option below:";

	mainMenu.addItem(
		new MenuItem(
			"Write \"Hello world!\"",  // Title of the item
			{writeln("Hello world!");} // This gets called when the item is selected
		)
	);

    ... add more items ...

    mainMenu.run();

will output something like:

Please choose an option below:
1 - Write "Hello world!"
... your items printed here ...
5 - Exit // This item is added automatically
> // Here you expect the user input

Don't worry about your user writing garbage to your menu's input. If the input cannot be matched to an item, a warning message (customizable) will be printed, and the menu shown again.

These are just the main things the library can do. Head over to the wiki and check out the documentation to learn how to make the most out of it.

Attributions

The following pieces of work make this library possible:

  • unit-threaded, by Atila Neves, released under the BSD-3-Clause license. Used for the testing of the library.
  • ArithEval, by Dechcaudron, released under the MIT license. Used for optional support of math expressions as user input.

dli's People

Contributors

dechcaudron avatar

Watchers

 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.