##// END OF EJS Templates
Command line examples added for non-parallel apps.
Brian Granger -
Show More
@@ -89,7 +89,9 b' class Application(SingletonConfigurable):'
89 89 option_description = Unicode(option_description)
90 90 keyvalue_description = Unicode(keyvalue_description)
91 91 subcommand_description = Unicode(subcommand_description)
92
92
93 # The usage and example string that goes at the end of the help string.
94 examples = Unicode()
93 95
94 96 # A sequence of Configurable subclasses whose config=True attributes will
95 97 # be exposed at the command line.
@@ -170,7 +172,7 b' class Application(SingletonConfigurable):'
170 172 self._log_formatter = logging.Formatter("[%(name)s] %(message)s")
171 173 self._log_handler.setFormatter(self._log_formatter)
172 174 self.log.addHandler(self._log_handler)
173
175
174 176 def initialize(self, argv=None):
175 177 """Do the basic steps to configure me.
176 178
@@ -285,6 +287,19 b' class Application(SingletonConfigurable):'
285 287 print p
286 288 print
287 289
290 def print_examples(self):
291 """Print usage and examples.
292
293 This usage string goes at the end of the command line help string
294 and should contain examples of the application's usage.
295 """
296 if self.examples:
297 print "Examples"
298 print "--------"
299 print
300 print indent(dedent(self.examples.strip()))
301 print
302
288 303 def print_version(self):
289 304 """Print the version string."""
290 305 print self.version
@@ -327,6 +342,7 b' class Application(SingletonConfigurable):'
327 342 if '-h' in argv or '--help' in argv or '--help-all' in argv:
328 343 self.print_description()
329 344 self.print_help('--help-all' in argv)
345 self.print_examples()
330 346 self.exit(0)
331 347
332 348 if '--version' in argv:
@@ -341,6 +357,7 b' class Application(SingletonConfigurable):'
341 357 except (TraitError, ArgumentError) as e:
342 358 self.print_description()
343 359 self.print_help()
360 self.print_examples()
344 361 self.log.fatal(str(e))
345 362 self.exit(1)
346 363 # store unparsed args in extra_args
@@ -79,7 +79,6 b' where you can edit ipython_config.py to start configuring IPython.'
79 79 #-----------------------------------------------------------------------------
80 80
81 81
82
83 82 class ProfileList(Application):
84 83 name = u'ipython-profile'
85 84 description = list_help
@@ -128,9 +127,15 b" create_flags.update(boolean_flag('parallel', 'ProfileCreate.parallel',"
128 127 "Include parallel computing config files",
129 128 "Don't include parallel computing config files"))
130 129
130 create_examples = """
131 ipython profile create foo # create profile foo
132 ipython profile create foo --init # create with default config files
133 """
134
131 135 class ProfileCreate(BaseIPythonApplication):
132 136 name = u'ipython-profile'
133 137 description = create_help
138 examples = create_examples
134 139 auto_create = Bool(True, config=False)
135 140
136 141 def _copy_config_files_default(self):
@@ -199,10 +204,16 b' class ProfileCreate(BaseIPythonApplication):'
199 204 def stage_default_config_file(self):
200 205 pass
201 206
207 main_examples = """
208 ipython profile create -h # show the help string for the create subcommand
209 ipython profile list -h # show the help string for the list subcommand
210 """
211
202 212 class ProfileApp(Application):
203 213 name = u'ipython-profile'
204 214 description = profile_help
205
215 examples = main_examples
216
206 217 subcommands = Dict(dict(
207 218 create = (ProfileCreate, "Create a new profile dir with default config files"),
208 219 list = (ProfileList, "List existing profiles")
@@ -218,6 +218,12 b' aliases.update(dict('
218 218 #-----------------------------------------------------------------------------
219 219 # IPythonQtConsole
220 220 #-----------------------------------------------------------------------------
221
222 qt_examples = """
223 ipython qtconsole # start the qtconsole
224 ipython qtconsole --pylab=inline # start with pylab in inline plotting mode
225 """
226
221 227 class IPythonQtConsoleApp(BaseIPythonApplication):
222 228 name = 'ipython-qtconsole'
223 229 default_config_file_name='ipython_config.py'
@@ -231,7 +237,8 b' class IPythonQtConsoleApp(BaseIPythonApplication):'
231 237 The QtConsole supports various extra features beyond the
232 238
233 239 """
234
240 examples = qt_examples
241
235 242 classes = [IPKernelApp, IPythonWidget, ZMQInteractiveShell, ProfileDir, Session]
236 243 flags = Dict(flags)
237 244 aliases = Dict(aliases)
@@ -168,12 +168,23 b' aliases.update(dict('
168 168 # Main classes and functions
169 169 #-----------------------------------------------------------------------------
170 170
171 examples = """
172 ipython --pylab # start in pylab mode
173 ipython --pylab=qt # start in pylab mode with the qt4 backend
174 ipython --log_level=DEBUG # set logging to DEBUG
175 ipython --profile=foo # start with profile foo
176 ipython qtconsole # start the qtconsole GUI application
177 ipython profile -h # show the help string for the profile subcmd
178 ipython qtconsole -h # show the help string for the qtconsole subcmd
179 """
180
171 181 class TerminalIPythonApp(BaseIPythonApplication, InteractiveShellApp):
172 182 name = u'ipython'
173 183 description = usage.cl_usage
174 184 default_config_file_name = default_config_file_name
175 185 crash_handler_class = IPAppCrashHandler
176
186 examples = examples
187
177 188 flags = Dict(flags)
178 189 aliases = Dict(aliases)
179 190 classes = [InteractiveShellApp, TerminalInteractiveShell, ProfileDir, PlainTextFormatter]
General Comments 0
You need to be logged in to leave comments. Login now