Skip to main content

Class based command line wrapper

Project description

Introduction
============
Skal is a 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
```

License
=======
Skal is licensed under Apache License 2.0

http://www.apache.org/licenses/LICENSE-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

skal-0.0.2.tar.gz (6.7 kB view details)

Uploaded Source

File details

Details for the file skal-0.0.2.tar.gz.

File metadata

  • Download URL: skal-0.0.2.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for skal-0.0.2.tar.gz
Algorithm Hash digest
SHA256 c3e26dc7438f3240f3dd6c50aacf2213fd153e30904b8d9a5632941ede0c1559
MD5 c20939ea04ad9a334cc7bb97dcc0e60d
BLAKE2b-256 abd1df08301c1f985d26069c8f196d050eddb8d782dd40fdf4a6bba4a130a513

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page