diff options
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/mof2wiki.sh | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tools/mof2wiki.sh b/tools/mof2wiki.sh new file mode 100755 index 0000000..bbd9b0f --- /dev/null +++ b/tools/mof2wiki.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +schemasurl='http://schemas.dmtf.org/wbem/cim-html/2.31.0/' + +usage() +{ + printf "$0 usage:\n" + printf "$0 file\n" + printf "$0 will read file and show which classes are defined in mof file " + printf "and print in pretty format usable easy in wiki\n" +} + +die() +{ + printf "%s\n" "$@" + exit 1 +} >&2 + +(( $# > 0 )) || die "Invalid number of parameters" + +if [[ "$1" == "-h" || "$1" == "--help" ]]; then + usage + exit 0 +fi + +moffile="$1" + +[[ -r "$moffile" ]] || die "$moffile is not readable" + +export LC_ALL=C + +printf "||= Defined class name =||= Inherited from =||\n" + +while IFS= read line; do + if [[ $line =~ ^class[[:blank:]]*([[:alnum:]_]*)":"[[:blank:]]*([[:alnum:]_]*) ]]; then + newclass=${BASH_REMATCH[1]} + derived=${BASH_REMATCH[2]} + printf "|| [wiki:%s %s] || [$schemasurl%s.html %s] ||\n" "$newclass" "$newclass" "$derived" "$derived" + fi +done < "$moffile" + |