Skip to content

Commit 4527f5c

Browse files
authored
Add -p everywhere (#145)
* Adopt -p with all commands, to specify the pot
1 parent 3b3aa3d commit 4527f5c

File tree

4 files changed

+27
-9
lines changed

4 files changed

+27
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1616
- info: -s to list available snapshots of a pot
1717
- clone: -s flag to explicitly choose the snapshot to clone
1818
- architecture: remove limitation of amd64 as the only architecture supported (#143 by jmg@)
19+
- start/stop/term/run: add support to -p potname on those commands, the only one not supporting it
1920

2021
### Changed
2122
- hostname: max default length for hostname set to 64 (#118)

share/pot/start.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# shellcheck disable=SC3033
44
start-help()
55
{
6-
echo "pot start [-h] [potname]"
6+
echo "pot start [-h] [-p] potname"
77
echo ' -h print this help'
88
echo ' -v verbose'
99
echo ' -s take a snapshot before to start'
@@ -562,8 +562,9 @@ pot-start()
562562
# shellcheck disable=SC3043
563563
local _pname _snap
564564
_snap=none
565+
_pname=
565566
OPTIND=1
566-
while getopts "hvsS" _o ; do
567+
while getopts "hvsSp:" _o ; do
567568
case "$_o" in
568569
h)
569570
start-help
@@ -578,13 +579,18 @@ pot-start()
578579
S)
579580
_snap=full
580581
;;
582+
p)
583+
_pname="$OPTARG"
584+
;;
581585
*)
582586
start-help
583587
${EXIT} 1
584588
;;
585589
esac
586590
done
587-
_pname="$( eval echo \$$OPTIND)"
591+
if [ -z "$_pname" ]; then
592+
_pname="$( eval echo \$$OPTIND)"
593+
fi
588594
if [ -z "$_pname" ]; then
589595
_error "A pot name is mandatory"
590596
start-help

share/pot/stop.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# shellcheck disable=SC3033
44
stop-help()
55
{
6-
echo "pot stop [-hv] [potname]"
6+
echo "pot stop [-hv] [-p] potname"
77
echo ' -h print this help'
88
echo ' -v verbose'
99
echo ' potname : the pot that has to stop'
@@ -147,9 +147,10 @@ pot-stop()
147147
{
148148
# shellcheck disable=SC3043
149149
local _pname
150+
_pname=
150151

151152
OPTIND=1
152-
while getopts "hv" _o; do
153+
while getopts "hvp:" _o; do
153154
case "$_o" in
154155
h)
155156
stop-help
@@ -158,13 +159,18 @@ pot-stop()
158159
v)
159160
_POT_VERBOSITY=$(( _POT_VERBOSITY + 1))
160161
;;
162+
p)
163+
_pname="$OPTARG"
164+
;;
161165
?)
162166
stop-help
163167
${EXIT} 1
164168
;;
165169
esac
166170
done
167-
_pname="$( eval echo \$$OPTIND)"
171+
if [ -z "$_pname" ]; then
172+
_pname="$( eval echo \$$OPTIND)"
173+
fi
168174
if [ -z "$_pname" ]; then
169175
_error "A pot name is mandatory"
170176
stop-help

share/pot/term.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# shellcheck disable=3033
55
term-help()
66
{
7-
echo "pot term [-h] [potname]"
7+
echo "pot term [-hvf] [-p] potname"
88
echo ' -h print this help'
99
echo ' -v verbose'
1010
echo ' -f force: it start the pot, if it'\''s not running'
@@ -32,7 +32,7 @@ pot-term()
3232
_force=
3333

3434
OPTIND=1
35-
while getopts "hvf" _o; do
35+
while getopts "hvfp:" _o; do
3636
case "$_o" in
3737
h)
3838
term-help
@@ -44,12 +44,17 @@ pot-term()
4444
f)
4545
_force="YES"
4646
;;
47+
p)
48+
_pname="$OPTARG"
49+
;;
4750
?)
4851
break
4952
;;
5053
esac
5154
done
52-
_pname="$(eval echo \$$OPTIND)"
55+
if [ -z "$_pname" ]; then
56+
_pname="$(eval echo \$$OPTIND)"
57+
fi
5358
if [ -z "$_pname" ]; then
5459
_error "A pot name is mandatory"
5560
term-help

0 commit comments

Comments
 (0)