Git Product home page Git Product logo

Comments (7)

neithere avatar neithere commented on August 27, 2024

Additions:

Varargs

#!python
def cmd(*paths):
    pass

# ...is the same as:

@arg('paths', nargs='*')
def cmd(paths):
    pass

# ...and same as:

@arg('paths', nargs='*')
@expects_obj
def cmd(args):
    pass

Keywords

**kwargs contains all arguments not fitting ArgSpec.args and ArgSpec.varargs. If ArgSpec.keywords in None, all @arg()'s will have to fit ArgSpec.args.

#!python

@arg('foo')
@arg('--bar', default=1)
def cmd(**kwargs):
    pass

# ...is the same as:

def cmd(foo, bar=1):
    pass

# ...and same as:

@arg('foo')
@arg('--bar', default=1)
@expects_obj
def cmd(args):
    pass

The first block does not require a default value to be specified.

Note: This comment has been automatically migrated from Bitbucket
Created by @neithere on 2012-12-26 09:15:24+00:00, last updated: 2012-12-26 16:01:27+00:00

from argh.

neithere avatar neithere commented on August 27, 2024

Backwards Compatibility

  1. The command() decorator becomes no-op. It may set an attribute though, see below. A deprecation warning is raised.
  2. If a function is not wrapped in command() and expects a single argument named args, it is likely to follow the old convention, i.e. implicitly expects a namespace object by default. After Argh is upgraded such function will break unless wrapped in expects_obj(). Therefore set_default_function() automatically wraps such function in expects_obj() to ease transition between the versions of API. A deprecation warning is raised.

Release 1.0 removes the command() decorator and the "magical" wrapping of func(args) in expects_obj().

Note: This comment has been automatically migrated from Bitbucket
Created by @neithere on 2012-12-27 07:45:46+00:00

from argh.

neithere avatar neithere commented on August 27, 2024

As DeprecationWarning is no longer loud since Python 2.7, it is required that the application developer runs the code as follows to ensure that the code is up to date:

#!bash
$ python -Wd app.py

Note: This comment has been automatically migrated from Bitbucket
Created by @neithere on 2012-12-27 10:38:48+00:00

from argh.

neithere avatar neithere commented on August 27, 2024

Re issue #29: implement new-style API, deprecate old functions, add compat fixes

Introspection/merging of varargs and keywords is not supported yet.

→ <>

Note: This comment has been automatically migrated from Bitbucket
Created by @neithere on 2012-12-27 16:11:31+00:00

from argh.

neithere avatar neithere commented on August 27, 2024

Re #29: add support for varargs.

→ <<cset 915a6aa05981>>

Note: This comment has been automatically migrated from Bitbucket
Created by @neithere on 2012-12-27 16:18:35+00:00

from argh.

neithere avatar neithere commented on August 27, 2024

Re #29: add support for varkw.

→ <>

Note: This comment has been automatically migrated from Bitbucket
Created by @neithere on 2012-12-27 16:18:35+00:00

from argh.

neithere avatar neithere commented on August 27, 2024

Well, the feature seems to be fully implemented and tested enough. Sure the code needs some refactoring and there are bugs yet to be found, but the issue can be closed.

Note: This comment has been automatically migrated from Bitbucket
Created by @neithere on 2012-12-30 16:34:04+00:00

from argh.

Related Issues (20)

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.