Giter Club home page Giter Club logo

vargs's Introduction

vargs 0.5

A simple argument parsing library for V. Ported from this file which was originally written on Typescript.

The version of this module will remain in 0.x.x unless the language API's are finalized and implemented.

// dummy.v
import vargs // or import nedpals.vargs for vpm users
import os

fn main() {
    // Second argument removes the first argument which contains the path of the executable.
    mut _args := vargs.new(os.args, 1)
    
    // Use the `alias` method if you want to map an option to an existing option.
    _args.alias('W', 'with')

    // Parsing is now a separate step
    _args.parse()

    println(_args.str())
    println(_args.command)
    println(_args.unknown[0])
    println('with? ' + _args.options['with'])
}
./dummy cook chicken --with love -W soul
# { command: "cook", options: {"with" => "love"}, unknown: ["chicken"] }
# cook
# chicken
# with? love,soul

Installation

Via vpm:

v install nedpals.vargs

Via vpkg:

vpkg get vargs

# or

vpkg get https://github.com/nedpals/vargs

Changes in 0.5

  1. Breaking change on the usage of the library.
  2. alias(orig, dest) for mapping options to existing ones.
  3. Array and the start index are now moved into the Args struct as internal fields.
  4. Default values are now moved inside the declaration of the Args struct.

Changes in 0.4

  1. Use comma-separated values of an option as array of strings with the array_option(name) function
  2. Fixed unused variable error.
  3. Options values are now merged if the name of the option has already existed.
  4. Fixed problem when installing module from VPM. #2
  5. Final stable release? Hmmm

0.4.1

  1. Merge duplicate codes into a function.
  2. Fixed another unused variable error.

0.4.2

  1. Fixed parsing errors when used in complex scenarios.
  2. Add proper tests.
  3. Now only works with 0.1.22 and above.
  4. Fixed maps formatting when converting Args to string.
  5. Partial refactoring of code including converting if statements to match

0.4.3

  1. Fix breaking changes when compiling on V 0.1.23

Contributing

  1. Fork it (https://github.com/nedpals/vargs/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Testing

To test the module, just type the following command:

v test vargs_test.v

License

MIT

Contributors

vargs's People

Contributors

dariotarantini avatar nedpals avatar tboerger 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

Watchers

 avatar  avatar  avatar  avatar

vargs's Issues

import vargs not found

v version: V 0.1.23 ed5c9a2

The import path must is import nedpals.vargs When i use v install nedpals.vargs or vpkg global install

Unable to use the vargs library

After running v install nedpals.args, I got vargs installed locally, however I'm unable to use the library. Here is a piece of feedback from my terminal:

Screen_Shot_2019-09-14_at_4 01 50_AM

I think the issue is happening because after downloading the library, the folder name is wrong. It's missing the v in vargs: /Users/voliveira/.vmodules/nedpals/args/.

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.