From dee5462fcac2816e458cf5f6fae21d58c29603f5 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Fri, 26 Jun 2015 14:28:32 -0700 Subject: [PATCH 1/2] install-nbextension -> nbextension install We decided the other week to namespace it like this to avoid having to change the way subcommands are found. --- notebook/nbextensions.py | 25 ++++++++++++++++--- ...nstall-nbextension => jupyter-nbextension} | 0 2 files changed, 22 insertions(+), 3 deletions(-) rename scripts/{jupyter-install-nbextension => jupyter-nbextension} (100%) diff --git a/notebook/nbextensions.py b/notebook/nbextensions.py index 82f70b9b9..713146715 100644 --- a/notebook/nbextensions.py +++ b/notebook/nbextensions.py @@ -256,14 +256,14 @@ aliases = { "destination" : "NBExtensionApp.destination", } -class NBExtensionApp(JupyterApp): +class InstallNBExtensionApp(JupyterApp): """Entry point for installing notebook extensions""" description = """Install Jupyter notebook extensions Usage - jupyter install-nbextension path/url + jupyter nbextension install path/url This copies a file or a folder into the Jupyter nbextensions directory. If a URL is given, it will be downloaded. @@ -273,7 +273,7 @@ class NBExtensionApp(JupyterApp): """ examples = """ - jupyter install-nbextension /path/to/myextension + jupyter nbextension install /path/to/myextension """ aliases = aliases flags = flags @@ -315,6 +315,25 @@ class NBExtensionApp(JupyterApp): print(str(e), file=sys.stderr) self.exit(1) +class NBExtensionApp(JupyterApp): + name = "jupyter nbextension" + + description = "Work with Jupyter notebook extensions" + + subcommands = dict( + install=(InstallNBExtensionApp, + """Install notebook extensions""" + ), + ) + + def start(self): + super(NBExtensionApp, self).start() + + # The above should have called a subcommand and raised NoStart; if we + # get here, it didn't, so we should print a message. + subcmds = ", ".join(sorted(self.subcommands)) + sys.exit("Please supply at least one subcommand: %s" % subcmds) + main = NBExtensionApp.launch_instance if __name__ == '__main__': diff --git a/scripts/jupyter-install-nbextension b/scripts/jupyter-nbextension similarity index 100% rename from scripts/jupyter-install-nbextension rename to scripts/jupyter-nbextension From 70885bd5ba20ef035bbdcb37d4cf7de6cb5979f6 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Fri, 26 Jun 2015 14:38:47 -0700 Subject: [PATCH 2/2] Update some references to NBExtensionApp --- notebook/nbextensions.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/notebook/nbextensions.py b/notebook/nbextensions.py index 713146715..68ad02e33 100644 --- a/notebook/nbextensions.py +++ b/notebook/nbextensions.py @@ -223,27 +223,27 @@ from jupyter_core.application import JupyterApp flags = { "overwrite" : ({ - "NBExtensionApp" : { + "InstallNBExtensionApp" : { "overwrite" : True, }}, "Force overwrite of existing files" ), "debug" : ({ - "NBExtensionApp" : { + "InstallNBExtensionApp" : { "verbose" : 2, }}, "Extra output" ), "quiet" : ({ - "NBExtensionApp" : { + "InstallNBExtensionApp" : { "verbose" : 0, }}, "Minimal output" ), "symlink" : ({ - "NBExtensionApp" : { + "InstallNBExtensionApp" : { "symlink" : True, }}, "Create symlink instead of copying files" ), "user" : ({ - "NBExtensionApp" : { + "InstallNBExtensionApp" : { "user" : True, }}, "Install to the user's IPython directory" ), @@ -251,9 +251,9 @@ flags = { flags['s'] = flags['symlink'] aliases = { - "prefix" : "NBExtensionApp.prefix", - "nbextensions" : "NBExtensionApp.nbextensions_dir", - "destination" : "NBExtensionApp.destination", + "prefix" : "InstallNBExtensionApp.prefix", + "nbextensions" : "InstallNBExtensionApp.nbextensions_dir", + "destination" : "InstallNBExtensionApp.destination", } class InstallNBExtensionApp(JupyterApp):