Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.2 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Libraries

    skal 0.1.13

    Download button

    No screenshots available
    Downloads: 139  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Max Persson | More programs
    The Apache License 2.0 / FREE
    September 25th, 2012, 09:08 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    skal description

    Class based command-line wrapper

    skal is a Python wrapper for the argparser library to make it easier to write applications that uses the command-subcommand style, much like git and heroku.

    Basic Usage

    Skal can be used on three levels: *class*, *module* and *package*. As this project is still very young only the class level is implemented as for now.

    In file myapp.py:

    python
    from skal import SkalApp, command

    class MyApp(SkalApp):
        @command
        def hello(self):
            print('hello')

        @command
        def yes(self):
            print('yes')

    if __name__ == '__main__':
        app = MyApp()
        sys.exit(app.run())


    Running the small program:

    > python myapp.py hello
    hello

    > python myapp.py yes
    yes


    Using Custom Arguments

    *Note: this is not yet implemented!*

    This shows the future usage of custom arguments per subcommand:

    python
    from skal import SkalApp, command, arguments


    class MyApp(SkalApp):
        """Application description""

        __arguments__ = {
            '-a': {'help': 'Help for a'},
            '-b': {'help': 'Help for b'}
        }

        @command
        @arguments({
            '-d': {'help': 'Help for d', 'alt': '--delete'}
        })
        def hello(self):
            """Help line for hello""
            if (self.args.a):
                print('a')
            if (self.args.b):
                print('b')
            if (self.args.delete):
                print('deleting')
            print('hello')

        @command
        def yes(self):
            """Help line for yes"""
            if (self.args.a):
                print('a')
            if (self.args.b):
                print('b')
            print('yes')

    if __name__ == '__main__':
        app = MyApp()
        sys.exit(app.run())


    Running it:

    > python myapp.py -a hello --delete
    a
    deleting
    hello

    > python myapp.py -b yes
    b
    yes



    Product's homepage

    Requirements:

    · Python

      


    TAGS:

    command-line wrapper | Python library | Python | command-line | wrapper

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM