skal

Class based command-line wrapper
Download

skal Ranking & Summary

Advertisement

  • Rating:
  • License:
  • The Apache License 2.0
  • Price:
  • FREE
  • Publisher Name:
  • Max Persson
  • Publisher web site:
  • https://github.com/looplab/

skal Tags


skal Description

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 UsageSkal 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:pythonfrom skal import SkalApp, commandclass 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 hellohello> python myapp.py yesyesUsing Custom Arguments*Note: this is not yet implemented!*This shows the future usage of custom arguments per subcommand:pythonfrom skal import SkalApp, command, argumentsclass 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 --deleteadeletinghello> python myapp.py -b yesbyesProduct's homepage


skal Related Software