Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mattboyer/optenum

optenum(1) is an option enumerator for command line executables.
https://github.com/mattboyer/optenum

Last synced: about 1 month ago
JSON representation

optenum(1) is an option enumerator for command line executables.

Awesome Lists containing this project

README

        

#optenum

optenum(1) is a command-line option enumerator for ELF executables.

Build status: [![Build Status](https://travis-ci.org/mattboyer/optenum.png)](https://travis-ci.org/mattboyer/optenum)
![Illustrative video](/doc/optenum.gif?raw=true)

optenum(1) uses static analysis to extract the options accepted by a binary and lets you use [bash](http://www.gnu.org/software/bash/)'s autocompletion with options.

` - ` - it's *magic*!

##Installing optenum

Building optenum is quick and easy. Download the source into a staging directory, run `cmake` then `make install`

```shell
$ git clone git://github.com/mattboyer/optenum.git
$ cd optenum/
$ cmake -DCMAKE_INSTALL_PREFIX:PATH=~/.local .
$ make install
```

**Note** The above will install optenum under the current user's home directory. For a system-wide install, replace the cmake invocation above with `cmake .`. This will cause optenum to be installed under `/usr/local/`, which will require elevated privileges.

All that's left to do is make sure the completion function is sourced and registered by your shell. You may want to add the following to your `~/.bashrc`:

```shell
. ~/.local/share/optenum/optenum.sh
```

##About

optenum(1) uses `libbfd` and `libopcodes` from the [GNU binutils](http://www.gnu.org/software/binutils/) package to parse the dynamic symbols used by a binary executable and disassemble its code.

When it finds a call to one of the supported option-parsing functions below, optenum will attempt to reconstitute the arguments passed as part of the call and, in the event the argument(s) that describes valid options has successfully been retrieved and points to a chunk of data hardcoded in the binary, finally parses it and exposes options to the user.

optenum(1) **never** executes foreign code and doesn't rely on any particular behaviour in the target binary. No usage message? No problem!

There are several moving parts and optenum operates on a best-effort basis. When optenum can't retrieve options, it will try to fail gracefully and fail fast.

##Support

###Option parsing functions

optenum(1) extracts options from binary executables by relying on the assumption that the task of defining valid command line options is done through a call to one of the following supported functions:

FunctionLibraryUsed by

getoptlibcGNU Coreutils, systemd utils, GNU NetCat and many more POSIX-compliant tools
getopt_long
getopt_long_only
g_option_context_add_main_entriesGlibGimp, Xchat,...
poptGetContextpoptSamba utils, logrotate, cryptsetup...

###Architectures

optenum(1) only supports `x86_64` argument passing conventions at this time.

##Contact

Please log any bugs you may encounter using the GitHub [issue tracker](https://github.com/mattboyer/optenum/issues) or alternatively send a mail to `mboyer sdf org`.