Code Monkey home page Code Monkey logo

args-parser's People

Contributors

igormironchik avatar nlohmann avatar px86 avatar thepreviousone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

args-parser's Issues

Use Case for redefining arguments

I have in my program 2 arguments that should Ideally work with a command to achieve different behavior than if used alone.
the idea is that if used alone the load specific files but if used as arguments of the init command would set the location of those files.
I don't know if this would be a common use case, but I thought it might be worth mentioning.

More documentation

Hi,

This args parser looks great, but would it be possible to document all the features more exhaustively?

Thanks.

Add support for commands in groups

I realized that with one-line syntax it's impossible to add command into any group. But it's very useful feature. So I'm going to implement it.

Improve documentation with examples

This library looks well featured and nicely designed.

Please add at least one more example to the README page that shows simple usage. Not subcommands. Just a simple example with parsing for a boolean flag, and an option with an argument. I'm an idiot, but nevertheless it still took me far me too long to find how to do this. For something as simple as an argparser, people want to copy and paste an example and edit it so they can get up and running quickly - putting only one example program (of the new version) on the README page that is subcommands is confusing.

Even better would be an example program showcasing several types of options, flags, options with argument(s), groups (if supported) etc.

All the best. In case it matters, I'm now using this library via conan after trying to use argh and being unable to understand it too.

connecting args and commands to functions

I am fully aware that this is a stupid question (but I also know I won't figure it out on my own)

I can't figure out how to connect and of my defined argument to actual functions to do anything useful
ie. unzip extract some-file or unzip -c directory would extract and compress things respectively
or even to set a value like in the help example example.help --host localhost --port 44 could set int port = 44

This looks like a cool library, and I plan to use it in a lot of current and past projects once I know how.

Name clashes if a class Command is declared in the global namespace

I've integrated the library v. 6.3.3 in a project, where one of the classes in the global namespace is named Command. This shouldn't be a problem, as the entire args-parser lirary is implemented in the namespace Args.
However, the class Args::ArgIface declares the class Commad to a friend:

class ArgIface {
	friend class CmdLine;
	friend class GroupIface;
	friend class Command; // this is meant to be Args::Command, not ::Command!
...

Because this is done before the class Args::Command declaration and after ::Command declaration, the compiler makes ::Command a friend instead of Args::Command. This leads to the protected member access compilation error.
The solution is to use a forward declaration of Command just before ArgIface declaration. Probably the same should be done to GroupIface (CmdLine is already forward-declared). Forward declaration makes the compiler aware of Args::Command class, and it is able to pick the correct one to make friend when declaring Args::ArgIface as expected.

Multiple redefinition when used in different files

When used in header only mode, during compilation I'm getting errors like:

/bin/ld: /tmp/ccItTpC3.o: in function `Args::details::isMisspelledName(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
setup.cpp:(.text+0x86): multiple definition of `Args::details::isMisspelledName(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'; /tmp/ccvkSDm2.o:main.cpp:(.text+0x86): first defined here
/bin/ld: /tmp/ccItTpC3.o:(.bss+0x0): multiple definition of `Args::MultiArg::m_emptyString[abi:cxx11]'; /tmp/ccvkSDm2.o:(.bss+0x0): first defined here
/bin/ld: /tmp/ccItTpC3.o:(.bss+0x20): multiple definition of `Args::GroupIface::m_dummyEmptyString[abi:cxx11]'; /tmp/ccvkSDm2.o:(.bss+0x20): first defined here
/bin/ld: /tmp/ccItTpC3.o:(.bss+0x40): multiple definition of `Args::g_argsOutStream'; /tmp/ccvkSDm2.o:(.bss+0x40): first defined here
/bin/ld: /tmp/ccItTpC3.o: in function `Args::details::formatCorrectNamesString(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&)':
setup.cpp:(.text+0x1d0): multiple definition of `Args::details::formatCorrectNamesString(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&)'; /tmp/ccvkSDm2.o:main.cpp:(.text+0x1d0): first defined here
collect2: error: ld returned 1 exit status

My software is g++ 10.2.1, Void GNU/Linux 5.18.7_1

Way to reproduce:

  • Create file main.cpp:
#include "args-parser/args-parser/all.hpp"

#include "setup.h"

int main(int argc, char* argv[])

{
	Args::CmdLine cmd{argc, argv};
	SetupCMD(cmd);
	return 0;
}
  • Create setup.h:
#ifndef SETUP_FUNCS_H
#define SETUP_FUNCS_H

#include "args-parser/args-parser/all.hpp"

void SetupCMD(Args::CmdLine &cmd);

#endif
  • Create setup.cpp:
#include "setup.h"
void SetupCMD(Args::CmdLine &cmd)
{
	cmd.addArgWithNameOnly("foo", true, true, "bar");
	cmd.parse();
}
  • Compile it with g++ main.cpp setup.cpp

Shadowed declaration

I'm playing around with the args-parser and our (quite restrictive) compiler settings generate a compilation error in help_printer.hpp at line 638:
declaration of 'cmd' shadows a previous local [-Werror=shadow]
Perhaps you should rename the lambda function's argument cmd.

Conan package

Hello,
Do you know about Conan?
Conan is modern dependency manager for C++. And will be great if your library will be available via package manager for other developers.

Here you can find example, how you can create package for the library.

If you have any questions, just ask :-)

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.