summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHans Ulrich Niedermann <hun@n-dimensional.de>2008-07-04 00:55:07 +0200
committerHans Ulrich Niedermann <hun@n-dimensional.de>2008-07-15 12:28:56 +0200
commit63fe2783e7ff50a9dfded18d42badbf6a1cf75de (patch)
tree1479fb0357b45d49153792ff0330e3a36ab41dfd /src
parentdead238a225a1a0a6be7857e6279771efdbc76ae (diff)
downloadnbb-63fe2783e7ff50a9dfded18d42badbf6a1cf75de.tar.gz
nbb-63fe2783e7ff50a9dfded18d42badbf6a1cf75de.tar.xz
nbb-63fe2783e7ff50a9dfded18d42badbf6a1cf75de.zip
Change from (sh|run)-(src|...) to --srcdir etc.
Diffstat (limited to 'src')
-rw-r--r--src/nbblib/commands.py58
-rw-r--r--src/nbblib/main.py39
2 files changed, 42 insertions, 55 deletions
diff --git a/src/nbblib/commands.py b/src/nbblib/commands.py
index 3f8e4fd..126500b 100644
--- a/src/nbblib/commands.py
+++ b/src/nbblib/commands.py
@@ -310,51 +310,41 @@ class MakeCommand(SourceClassCommand):
class GeneralRunCommand(SourceClassCommand):
"""Run general command in some branch specific dir
- Non-abstract derived classes MUST define run_in as one of
- ['srcdir', 'builddir', 'installdir'].
"""
- name = None
- summary = 'run some command in some dir'
+ name = 'run'
+ summary = 'run some command in branch specific dir'
validate_args = Command.validate_args_any
- def get_run_in_dir(self):
- return {
- 'srcdir': self.bs_sourcetree.config.srcdir,
- 'builddir': self.bs_sourcetree.config.builddir,
- 'installdir': self.bs_sourcetree.config.installdir,
- }[self.run_in]
+ def __init__(self, context, *args, **kwargs):
+ super(GeneralRunCommand, self).__init__(context, *args, **kwargs)
+ self.rundir = None
+ self.run_in = 'builddir'
+ if len(self.args):
+ if self.args[0] == '--srcdir':
+ self.args = self.args[1:]
+ self.rundir = self.bs_sourcetree.config.srcdir
+ self.run_in = 'srcdir'
+ elif self.args[0] == '--installdir':
+ self.args = self.args[1:]
+ self.rundir = self.bs_sourcetree.config.installdir
+ self.run_in = 'installdir'
+ elif self.args[0] == '--builddir':
+ self.args = self.args[1:]
+ if not self.rundir:
+ self.rundir = self.bs_sourcetree.config.builddir
def chdir(self):
- rundir = self.get_run_in_dir()
- if os.path.exists(rundir):
- os.chdir(rundir)
+ if os.path.exists(self.rundir):
+ os.chdir(self.rundir)
else:
raise RuntimeError("The %s directory %s does not exist"
- % (self.run_in, repr(rundir)))
+ % (self.run_in, repr(self.rundir)))
def run(self):
self.chdir()
progutils.prog_run(list(self.args), self.context)
-class RunSrcCommand(GeneralRunCommand):
- name = 'run-src'
- summary = 'run given command in source dir'
- run_in = 'srcdir'
-
-
-class RunBuildCommand(GeneralRunCommand):
- name = 'run-build'
- summary = 'run given command in build dir'
- run_in = 'builddir'
-
-
-class RunInstallCommand(GeneralRunCommand):
- name = 'run-install'
- summary = 'run given command in install dir'
- run_in = 'installdir'
-
-
class GeneralShellCommand(GeneralRunCommand):
- name = None
- summary = 'run shell in some dir'
+ name = 'sh'
+ summary = 'run shell in branch specific dir'
def get_shell_prompt(self):
return r",--[Ctrl-d or 'exit' to quit this %s shell for branch '%s']--\n| <%s %s> %s\n\`--[\u@\h \W]\$ " \
% (self.context.prog, self.vcs_sourcetree.branch_name,
diff --git a/src/nbblib/main.py b/src/nbblib/main.py
index 5a7386e..8798608 100644
--- a/src/nbblib/main.py
+++ b/src/nbblib/main.py
@@ -17,7 +17,7 @@ Features:
* does out-of-source-tree builds (in-source-tree-builds unsupported)
* direct support for automake/autoconf based build systems
-TBD: Command line interface:
+Command line interface (implemeted):
Run default build commands:
$ %(prog)s [general options] init [command specific options]
@@ -25,6 +25,23 @@ TBD: Command line interface:
$ %(prog)s [general options] build [command specific options]
$ %(prog)s [general options] install [command specific options]
+ Get/set config:
+ $ %(prog)s [general options] config srcdir
+ $ %(prog)s [general options] config builddir [<builddir>]
+ $ %(prog)s [general options] config installdir [<installdir>]
+
+ Start an interactive shell in either of the three directories:
+ $ %(prog)s [general options] sh --srcdir [command specific options]
+ $ %(prog)s [general options] sh [--builddir] [command specific options]
+ $ %(prog)s [general options] sh --installdir [command specific options]
+
+ Run command in either of the three directories:
+ $ %(prog)s [general options] run --srcdir <command> [<param>...]
+ $ %(prog)s [general options] run [--builddir] <command> [<param>...]
+ $ %(prog)s [general options] run --installdir <command> [<param>...]
+
+TBD: Command line interface:
+
Run cleanup commands:
$ %(prog)s [general options] purge [command specific options]
Command specific options:
@@ -34,26 +51,6 @@ TBD: Command line interface:
$ %(prog)s [general options] purge --all # or that
TBD: 'make clean', 'make distclean' and similar stuff?
- Get/set config:
- $ %(prog)s [general options] config srcdir
- $ %(prog)s [general options] config builddir [<builddir>]
- $ %(prog)s [general options] config installdir [<installdir>]
-
- Start an interactive shell in either of the three directories:
- $ %(prog)s [general options] src-sh [command specific options]
- $ %(prog)s [general options] build-sh [command specific options]
- $ %(prog)s [general options] install-sh [command specific options]
-
- Run command in builddir:
- $ %(prog)s [general options] run <command> [<param>...]
- $ %(prog)s [general options] run [command specific options... <-->] <cmd>...
-
- (Not sure about these)
- Run a non-interactive shell command in either of the three directories:
- $ %(prog)s [general options] src-sh [command specific options] <command>...
- $ %(prog)s [general options] build-sh [command specific options] <command>...
- $ %(prog)s [general options] install-sh [command specific options] <cmd...>
-
Global options:
-h --help Print this help text