Coder Social home page Coder Social logo

yaggo's Introduction

What is yaggo?

Yaggo is a tool to generate command line parsers for C++. Yaggo stands for "Yet Another GenGetOpt" and is inspired by GNU Gengetopt.

It reads a configuration file describing the switches and argument for a C++ program and it generates one header file that parses the command line using getopt_long(3). See the Example section below for more details.

Installation

Quick and easy

Download the standalone script called yaggo from the release and copy it into a directory in your PATH (e.g. ~/bin)

From the source tree, the same is achieved with:

make install prefix=$HOME/bin

As a gem

Install directly with the gem command:

gem install yaggo

(Use the --user-install to install in your home instead of globally).

Alternatively, download the gem from the release and install it with sudo gem install ./yaggo-x.x.x.gem (adjust the version!).

Similarly, from the source tree, first generate the gem and then install it. For example:

rake gem
sudo gem install ./pkg/yaggo-x.x.x.gem

Documentation

After installation, documentation is available with yaggo --man.

Simple example

Given the following configuration file 'parser.yaggo':

purpose "Demonstrate yaggo capabilities"
description "This simple configuration file shows some of the capabilities of yaggo.
This is supposed to be a longer description of the program.
"

option("f", "flag") {
  description "This is a flag"
  off
}
option("i", "int") {
  description "This take an integer"
  int
  default 20
}
arg("path") {
  description "Path to file"
  c_string
}

The following C++ program ('parser.cc') does switch parsing, generate appropriate errors and has an automatically generated help (accessible with '-h' or '--help').

#include <iostream>
#include "parser.hpp"

int main(int argc, char* argv[]) {
  parser args(argc, argv); // Does all the parsing

  std::cout << "--flag " << (args.flag_flag ? "not passed" : "passed") << "\n"
            << "--int: " << args.int_arg << "\n"
            << "path: " << args.path_arg << "\n";

  return 0;
}

All of this is compiled with:

yaggo parser.yaggo
g++ -o parser parser.cc

Then, './parser --help' returns:

Usage: parser [options] path:string

Demonstrate yaggo capabilities

This simple configuration file shows some of the capabilities of yaggo.
This is supposed to be a longer description of the program.

Options (default value in (), *required):
 -f, --flag                               This is a flag (false)
 -i, --int=int                            This take an integer (20)
 -U, --usage                              Usage
 -h, --help                               This message
 -V, --version                            Version

yaggo's People

Contributors

gmarcais avatar dunn avatar wwood avatar sebastien-lemieux avatar

Stargazers

Pepijn Kooij avatar Tuukka Norri avatar Alexander Galato avatar Barış Ekim avatar Timothy Drew Collingsworth avatar Barry Gu avatar Claire Chung avatar Pawel Cyrta avatar Yosuke Tanigawa avatar Dino Korah avatar Saket Choudhary avatar Shaun Jackman avatar Rob Patro avatar Haibao Tang avatar  avatar

Watchers

James Cloos avatar  avatar

yaggo's Issues

make test doesn't work

Hi,

I'm trying to package jellyfish for guix, which requires packaging yaggo:
http://lists.gnu.org/archive/html/guix-devel/2015-06/msg00496.html

One thing that would be helpful would be to get the tests to run. Currently there's a problem (separate to the one mentioned in the mailing list), unless I am missing something:

$ cd test
$ make
make: *** No rule to make target 'count.yaggo', needed by 'count_cmdline.hpp'.  Stop.

Thanks,
ben

Install instructions incomplete

The installation instructions say:

Download the standalone script from the release and copy it into a directory in your PATH (e.g. ~/bin)

From the source tree, the same is achieved with:

make DEST=$HOME/bin

This doesn't work:

bli@latimeria:~/src$ git clone https://github.com/gmarcais/yaggo.git
Cloning into 'yaggo'...
remote: Counting objects: 542, done.
remote: Total 542 (delta 0), reused 0 (delta 0), pack-reused 542
Receiving objects: 100% (542/542), 141.23 KiB | 0 bytes/s, done.
Resolving deltas: 100% (276/276), done.
bli@latimeria:~/src$ cd yaggo/
bli@latimeria:~/src/yaggo$ l
total 104K
-rw-r--r-- 1 bli bli 2.8K mars  13 10:16 README.md
-rw-r--r-- 1 bli bli   14 mars  13 10:16 README
-rw-r--r-- 1 bli bli 1.5K mars  13 10:16 Rakefile
-rw-r--r-- 1 bli bli  375 mars  13 10:16 Makefile
drwxr-xr-x 3 bli bli 4.0K mars  13 10:16 lib/
-rw-r--r-- 1 bli bli  35K mars  13 10:16 COPYING
drwxr-xr-x 2 bli bli 4.0K mars  13 10:16 bin/
drwxr-xr-x 2 bli bli 4.0K mars  13 10:16 test/
-rw-r--r-- 1 bli bli  36K mars  13 10:16 setup.rb
-rw-r--r-- 1 bli bli  642 mars  13 10:16 license-header.txt
bli@latimeria:~/src/yaggo$ make DEST=$HOME/bin
ruby bin/create_yaggo_one_file ./yaggo
bli@latimeria:~/src/yaggo$ l
total 164K
-rw-r--r-- 1 bli bli 2.8K mars  13 10:16 README.md
-rw-r--r-- 1 bli bli   14 mars  13 10:16 README
-rw-r--r-- 1 bli bli 1.5K mars  13 10:16 Rakefile
-rw-r--r-- 1 bli bli  375 mars  13 10:16 Makefile
drwxr-xr-x 3 bli bli 4.0K mars  13 10:16 lib/
-rw-r--r-- 1 bli bli  35K mars  13 10:16 COPYING
drwxr-xr-x 2 bli bli 4.0K mars  13 10:16 bin/
drwxr-xr-x 2 bli bli 4.0K mars  13 10:16 test/
-rw-r--r-- 1 bli bli  36K mars  13 10:16 setup.rb
-rw-r--r-- 1 bli bli  642 mars  13 10:16 license-header.txt
-rwxr-xr-x 1 bli bli  59K mars  13 10:17 yaggo*

The binary seems to have been created, but not installed at the destination.

I then tried to make install, but this did not work:

bli@latimeria:~/src/yaggo$ make install
ruby bin/create_yaggo_one_file ./yaggo
mkdir -p /usr/local/bin
mkdir -p /usr/local/share/doc/yaggo
mkdir: cannot create directory ‘/usr/local/share/doc/yaggo’: Permission denied
Makefile:7: recipe for target 'install' failed
make: *** [install] Error 1

Setting the DEST variable seems to have no effect:

bli@latimeria:~/src/yaggo$ make DEST=$HOME/bin install
ruby bin/create_yaggo_one_file ./yaggo
mkdir -p /usr/local/bin
mkdir -p /usr/local/share/doc/yaggo
mkdir: cannot create directory ‘/usr/local/share/doc/yaggo’: Permission denied
Makefile:7: recipe for target 'install' failed
make: *** [install] Error 1

Can't work on MSYS2

Hi !
I have git clone your yaggo project to my msys2 home directory.
I have installed all the tools that needed by the yaggo,sush as make , ruby, gcc.
But when i do : yaggo parser.yaggo,then it tell me:

 D:/msys64/home/lovel/bin/yaggo:102:in `fork': fork() function is unimplemented on this machine  (NotImplementedError)
        from D:/msys64/home/lovel/bin/yaggo:102:in `block in main'
        from D:/msys64/home/lovel/bin/yaggo:101:in `each'
        from D:/msys64/home/lovel/bin/yaggo:101:in `main'
        from D:/msys64/home/lovel/bin/yaggo:6:in `<main>'``

Can you help me? Thanks very much!

Makefile does not respect DESTDIR variable

Hi,
it is common that Makefile.am rules respect $(DESTDIR) variable which value get preprended in front of $(PREFIX), so that files are installe din the desired place.

>>> Install yaggo-1.5.9 into /scratch/var/tmp/portage/dev-lang/yaggo-1.5.9/image/ category dev-lang
make -j2 DESTDIR=/scratch/var/tmp/portage/dev-lang/yaggo-1.5.9/image/ install 
ruby bin/create_yaggo_one_file ./yaggo
mkdir -p /usr/local/bin
mkdir -p /usr/local/share/doc/yaggo
 * ACCESS DENIED:  mkdir:        /usr/local/share
mkdir: cannot create directory '/usr/local/share': Permission denied

Fix is simple:

sed -e 's/$(prefix)/$(DESTDIR)$(prefix)/g' -i Makefile

won't compile

setup.rb:788 Use RbConfig instead of obsolete and deprecated Config
no such file or directory - .config
setup.rb config first
try 'ruby setup.rb --help' for detailed usage

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.