summaryrefslogtreecommitdiffstats
path: root/lsinitcpio
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2012-09-27 19:59:26 +0200
committerDave Reisner <dreisner@archlinux.org>2012-09-30 00:06:09 +0200
commitc396a58ba7d4ce9f7087379537fa2251a90af52a (patch)
treeae4a2e8ec42ce82c4f8de4e4038feb7796ced821 /lsinitcpio
parent887511601787db60b5692802fc2ccdfd47c0d698 (diff)
downloadmkinitcpio-c396a58ba7d4ce9f7087379537fa2251a90af52a.tar.gz
mkinitcpio-c396a58ba7d4ce9f7087379537fa2251a90af52a.tar.xz
lsinitcpio: add -l, --list option; define as default
This is the default action for lsinitcpio. Add it just for the purpose of clarity. This change also separates out true options from 'actions' and validates that the user only passed a single action to lsinitcpio. Update the manpage accordingly. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Diffstat (limited to 'lsinitcpio')
-rwxr-xr-xlsinitcpio23
1 files changed, 18 insertions, 5 deletions
diff --git a/lsinitcpio b/lsinitcpio
index 1d4a343..2dc7d35 100755
--- a/lsinitcpio
+++ b/lsinitcpio
@@ -14,15 +14,18 @@ declare FUNCTIONS=functions
usage() {
cat<<USAGE
lsinitcpio %VERSION%
-usage: ${0##*/} [options] <initramfs>
+usage: ${0##*/} [action] [options] <initramfs>
- Options:
+ Actions:
-a, --analyze analyze contents of image
-c, --config show configuration file image was built with
+ -l, --list list contents of the image (default)
+ -x, --extract extract image to disk
+
+ Options:
-h, --help display this help
-n, --nocolor disable colorized output
-v, --verbose more verbose output
- -x, --extract extract image to disk
USAGE
}
@@ -163,8 +166,8 @@ analyze_image() {
fi
}
-OPT_SHORT='achnvx'
-OPT_LONG=('analyze' 'help' 'nocolor' 'showconfig' 'verbose' 'extract')
+OPT_SHORT='achlnvx'
+OPT_LONG=('analyze' 'help' 'list' 'nocolor' 'showconfig' 'verbose' 'extract')
if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
exit 1
@@ -181,6 +184,8 @@ while :; do
-h|--help)
usage
exit 0 ;;
+ -l|--list)
+ listcontents=1 ;;
-n|--nocolor)
color=0 ;;
-v|--verbose)
@@ -219,6 +224,14 @@ readonly NC BOLD BLUE GREEN RED YELLOW
[[ $image ]] || die "No image specified (use -h for help)"
[[ -f $image ]] || die "No such file: $image"
+case $(( analyze + listcontents + showconfig )) in
+ 0)
+ # default action when none specified
+ listcontents=1 ;;
+ [!1])
+ die "Only one action may be specified at a time" ;;
+esac
+
# read compression type
case "$(file -Lb "$image")" in
@(data|LZMA)*) compress=lzma ;;