summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bash-completion3
-rwxr-xr-xlsinitcpio23
-rw-r--r--lsinitcpio.1.txt17
3 files changed, 32 insertions, 11 deletions
diff --git a/bash-completion b/bash-completion
index 4e548af..6ef4e93 100644
--- a/bash-completion
+++ b/bash-completion
@@ -3,7 +3,8 @@
_lsinitcpio() {
local cur opts
- opts=(-a --analyze -c --config -h --help -n --nocolor -v --verbose -x --extract)
+ opts=(-a --analyze -c --config -h --help -l --list
+ -n --nocolor -v --verbose -x --extract)
_get_comp_words_by_ref cur
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 ;;
diff --git a/lsinitcpio.1.txt b/lsinitcpio.1.txt
index 63b5566..d1ffeb7 100644
--- a/lsinitcpio.1.txt
+++ b/lsinitcpio.1.txt
@@ -10,14 +10,14 @@ lsinitcpio - Examine an initramfs
Synopsis
--------
-'lsinitcpio' [options] 'image'
+'lsinitcpio' [action] [options] 'image'
Description
-----------
Examines the contents of an initcpio image. Without any options, 'lsinitcpio'
simply lists the contents of an image.
-Options
+Actions
-------
*-a, \--analyze*::
Analyze the contents of the specified image and print output in human
@@ -26,6 +26,16 @@ Options
*-c, \--config*::
Show the configuration file the given image was built with.
+*-l, \--list*::
+ List the contents of the archive. This is the default action. Pass the *-v*
+ flag for more detailed results.
+
+*-x, \--extract*::
+ Extract the given image to the current working directory.
+
+Options
+-------
+
*-h, \--help*::
Output a short overview of available command-line switches.
@@ -37,9 +47,6 @@ Options
the contents of an image, and show files as they are extracted when
the *-x* option is given.
-*-x, \--extract*::
- Extract the given image to the current working directory.
-
Bugs
----
Upon writing this manpage, there were no noticeable bugs present. Please visit