Skip to content

A single-file library for detecting and handling common program arguments (--help, --version, -v, -h etc.) in multiple programming languages

License

Notifications You must be signed in to change notification settings

TechnicFully/Help-Handler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HelpHandler


Raison D’être

Having used countless programs from the commandline, the lack of user friendliness has always been frustrating, as well as the amount of boilerplate that would be copy/pasted from other projects to handle the very basic task of telling a user how to use the program, and what version of the program they’re using is. I came across various projects for handling arguments, but none for help/version dialogue specifically, let alone in the many various programming languages that one may use. In many popular projects, simply trying to get usage help is a roll of the dice as to what argument works (nano doesn’t support "help", openssl and gcc only support "help" and "--help" respectively, etc.), and are case-sensitive which is not user friendly. Even Python’s argparse throws "unrecognized arguments" for anything but "--help".

This library isn’t meant to be another argument parser, but a one-file library to accomplish the simple task of outputting help dialogue and/or version information to be used with other libraries, in numerous programming languages.

Language minimum versions
  • C          - C99

  • C++     - C++11

  • Java     - 7

  • Lua       - 5.3.5

  • Python - 2.7.17 and 3.7+

Usage

Only one function call is required after importing/including the respective language’s Help-Handler file. Most users will only be concerned with the config() function to enable/disable matching of arguments which might conflict with your program (h, -h, --h, v, -v, --v), and version() to pass your program’s version.

You can refer to the readme and examples folder in each language’s folder for basic and more advanced usage, though there are few functions.

C
help_handler(argc, argv, "Usage: Test");
C++
helpHandler::handle(argc, argv, "Usage: Test");
Python
HelpHandler.handle("Usage: Test")
Java
HelpHandler.handle(args, "Usage: Test");
Lua
HelpHandler.handle("Usage: Test")

Example

example terminal screenshot

Planned Features

  • Support for unicode in all language implementations. Some languages such as Python support this natively, but others often don’t.

  • Returning what type of arguments specifically were matched. This will allow using other libraries for handling options parsing without conflicts

  • Line break at spaces according to terminal width

  • Option to output specific dialogue on first program run

Contributing

If you’d like to submit a bugfix, I’d be glad to take a pull request or fix it myself given adequate description of the cause of the issue. If you’d like a feature added, it will be considered so long as it’s within the scope of this project.

License

Distributed under the MIT License. See here for more information.