Skip to content

Commit

Permalink
Merge pull request #176 from takluyver/subcmd-nbextension-install
Browse files Browse the repository at this point in the history
install-nbextension -> nbextension install
  • Loading branch information
minrk committed Jun 28, 2015
2 parents 0ceeb5c + 70885bd commit 3ee4efd
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 11 deletions.
41 changes: 30 additions & 11 deletions notebook/nbextensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,47 +223,47 @@ def install_nbextension(path, overwrite=False, symlink=False, user=False, prefix

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"
),
}
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 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.
Expand All @@ -273,7 +273,7 @@ class NBExtensionApp(JupyterApp):
"""

examples = """
jupyter install-nbextension /path/to/myextension
jupyter nbextension install /path/to/myextension
"""
aliases = aliases
flags = flags
Expand Down Expand Up @@ -315,6 +315,25 @@ def start(self):
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__':
Expand Down
File renamed without changes.

0 comments on commit 3ee4efd

Please sign in to comment.