GitXplorerGitXplorer
m

libargs

public
12 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
ce48b5d426088cba9e16f2d0b3f564a7d2c4d50b

Update README

mmcinglis committed 9 years ago
Unverified
36b99348475575668f7b64dd93956a7662fa09c4

Fix is-empty check bug

mmcinglis committed 10 years ago
Unverified
79df8f8d960c2e45d0dabe253687ae89af5a3ecf

Change default arg parser func to deny empty strs

mmcinglis committed 10 years ago
Unverified
fa6f35fd0252b034547745f0286d7d7650e623d7

Update Libbase to v3

mmcinglis committed 10 years ago
Unverified
144b34bf1b9c285f50c076fb4709fbdcec102cfd

Rename files to latest naming convention

mmcinglis committed 10 years ago
Unverified
6630f8fb41767cca298ea66e4e8913fd4342e863

Update dependencies, improve API

mmcinglis committed 10 years ago

README

The README file for this repository.

Libargs provides functions for parsing arguments according to a declarative specification:

ArgsError err = { .type = ArgsError_NONE };
argparse( argc, argv, &err, ( ArgSpec ){
    .positionals = ARRAY_ARGPOSITIONAL(
        { .name        = "system-id",
          .destination = &system_id
        },
        { .name        = "api-key",
          .destination = &api_key
        }
    ),
    .flags = ARRAY_ARGFLAG(
        { .name        = "--version",
          .destination = &got_version_flag
        },
        { .names       = ARRAY_STR( "--help", "-h" ),
          .destination = &got_help_flag
        }
    ),
    .options = ARRAY_ARGOPTION(
        { .name        = "--widget-file",
          .destination = &widget_file
        },
        { .names       = ARRAY_STR( "--times", "-t" ),
          .destination = &times,
          .num_args    = { .min = ArgsNum_NONE, .max = ArgsNum_INFINITE },
          .parser      = time__arg_parse
        }
    )
} );
if ( err.type != ArgsError_NONE ) {
    // handle error
}
// use values set from `argparse()`...

See examples/demo.c for a full example.

Releases

I'll tag the releases according to semantic versioning. All the macros preceded by // @public are considered public: they'll only change between major versions. The other macros could change any time. Non-preprocessor identifiers defined in header files are always considered public. New identifiers prefixed with arg (any case) will not warrant a major version bump.

Every version tag will be signed with my GPG key (fingerprint: 0xD020F814).

Dependencies

Package.json specifies the dependencies of Libargs: where to get them, and what version to use. I've developed a tool called Puck that will parse such a Package.json, download the specified repositories, check out the specified version, and, if the dependency has its own Package.json, repeat that process for its dependencies. With puck on your PATH, in the directory of Libargs:

$ puck update
$ puck execute build

There's nothing magic to what Puck does, so if you would prefer, you can set up the dependencies manually. You just need to have the dependencies in the deps directory within the Libargs directory, and have them built (if necessary) before building Libargs.

There is no build command specified for Libargs, because you should manage the building of Libargs' sources in your own project. The dependencies rely on generated source files, and you would want to have that process integrated with the rest of your project, avoiding multiple libraries trying to generate the same file differently. Nonetheless, there is a Makefile provided that will build the object files and example programs.

Collaboration

Libargs is available at Bitbucket and GitHub.

Questions, discussion, bug reports and feature requests are welcome at the GitHub issue tracker, or via emails.

To contribute changes, you're welcome to email me patches as per git format-patch, or to send me a pull request on any of the aforementioned sites. You're also welcome to just send me a link to your remote repository, and I'll merge stuff from that as I want to.

To accept notable contributions, I'll require you to assign your copyright to me. In your email/pull request and commit messages, please insert: "I hereby irrevocably transfer to Malcolm Inglis (http://minglis.id.au) all copyrights, title, and interest, throughout the world, in these contributions to Libargs". If you can, please sign the email or pull request, ensuring your GPG key is publicly available.

License

Copyright 2015 Malcolm Inglis http://minglis.id.au

Libargs is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Libargs is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with Libargs If not, see https://gnu.org/licenses/.

Contact me for proprietary licensing options.

Why AGPL?

I believe that nonfree software is harmful, and I don't want to contribute to its development at all. I believe that a free society must necessarily operate on free software. I want to encourage the development of free software, and discourage the development of nonfree software.

The GPL was designed to ensure that the software stays free software; "to ensure that every user has freedom". The GPL's protections may have sufficed in 1990, but they don't in 2015. The GPL doesn't consider users of a web service to be users of the software implementing that server. Thankfully, the AGPL does.

The AGPL ensures that if Libargs is used to implement a web service, then the entire source code of that web service must be free software. This way, I'm not contributing to nonfree software, whether it's executed locally or provided over a network.