Skip to content

Commit 154b78d

Browse files
committed
Merge pull request #222 from ngavalas/non-interactive
add a command-line flag to force non-interactive mode
2 parents ccc8e37 + c61192d commit 154b78d

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

fpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ done
2121
BASEDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
2222

2323
PYTHONCMD="python"
24+
NONINTERACTIVE=false
2425

2526
function doProgram {
2627
# process input from pipe and store as pickled file
@@ -34,7 +35,7 @@ function doProgram {
3435
$PYTHONCMD "$BASEDIR/src/choose.py" "$@" < /dev/tty
3536
# Determine if running from within vim shell
3637
IFLAG=""
37-
if [ -z "$VIMRUNTIME" ]; then
38+
if [ -z "$VIMRUNTIME" -a "$NONINTERACTIVE" = false ]; then
3839
IFLAG="-i"
3940
fi
4041
# execute the output bash script. For zsh or bash
@@ -67,6 +68,8 @@ for opt in "$@"; do
6768
exit 0
6869
elif [ "$opt" == "--record" -o "$opt" == "-r" ]; then
6970
echo "Recording input and output..."
71+
elif [ "$opt" == "--non-interactive" -o "$opt" == "-ni" ]; then
72+
NONINTERACTIVE=true
7073
elif [ "$opt" == "--keep-open" -o "$opt" == "-ko" ]; then
7174
# allow control-c to exit the loop
7275
# http://unix.stackexchange.com/a/48432

src/screenFlags.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ def getDisableFileChecks(self):
4545
def getAllInput(self):
4646
return self.args.all_input
4747

48+
def getIsNonInteractive(self):
49+
return self.args.non_interactive
50+
4851
@staticmethod
4952
def getArgParser():
5053
parser = argparse.ArgumentParser(prog='fpp')
@@ -102,6 +105,16 @@ def getArgParser():
102105
help='''You may force PathPicker to recognize all
103106
lines as acceptible input. Typically, PathPicker will scan the input for references
104107
to file paths. Passing this option will disable those scans and the program will assume that every input line is a match. In practice, this option allows for input selection for a variety of sources that would otherwise be unsupported -- git branches, mercurial bookmarks, etc.''')
108+
parser.add_argument('-ni',
109+
'--non-interactive',
110+
default=False,
111+
action="store_true",
112+
help='''Normally, the command that runs after you've
113+
chosen files to operate on is spawned in an interactive subshell. This allows you
114+
to use aliases and have access to environment variables defined in your startup
115+
files, but can have strange side-effects when starting and stopping jobs
116+
and redirecting inputs. Using this flag runs your commands in a non-interactive subshell,
117+
like a normal shell script.''')
105118
return parser
106119

107120
@staticmethod

0 commit comments

Comments
 (0)