Browse Source

Generate README with Linux and MacOS applications

master
Maxim Likhachev 5 years ago
parent
commit
7c3c76bd6e
  1. 103
      scripts/doc.sh
  2. 51
      scripts/doc.tpl

103
scripts/doc.sh

@ -1,6 +1,24 @@ @@ -1,6 +1,24 @@
#!/bin/bash
MACOS_FILE=roles/macos/vars/main.yml
CWD=$(dirname "$0")
source "$CWD/doc.tpl"
MACOS_FILE=$CWD/../roles/macos/vars/main.yml
LINUX_FILE=$CWD/../roles/linux-gentoo/vars/applications.yml
APP_ALIASES=$(cat <<-EOF
haskell-stack:stack-bin
ghostscript:ghostscript-gpl
ntfs-3g:ntfs3g
firefox:firefox-bin
shellcheck:shellcheck-bin
EOF
)
get_alias() {
grep -E ":?${1}:?" <<<"${APP_ALIASES[*]}" | sed -E "s/:?${1}:?//"
}
description() {
application=$1
@ -17,64 +35,65 @@ description() { @@ -17,64 +35,65 @@ description() {
printf -- "- %s[%s](%s) - %s%s\n" "$marks" "$app_name" "$app_page" "$app_dscr" "$marks"
}
MACOS_APPS=$(grep -E '^\s*(#\s)?-\s+[^:]+\s+#\s*http.+$' "$MACOS_FILE" \
get_apps() {
grep -E '^\s*(#\s)?-\s+[^:]+\s+#\s*http.+$' "$1" \
| expand \
| sort \
| sed -E 's/[[:space:]]+/ /g; s/^[[:space:]]*//'
)
apps_macos=""
while read -r app; do
disabled=
if [ "${app:0:1}" == '#' ]; then
app=$(cut -d ' ' -f 2- <<<"$app")
disabled=1
fi
apps_macos+=$(description "$app" "$disabled")
apps_macos+='\n'
done <<<"$MACOS_APPS"
# ------------------------------------------------------------------------------
echo -e "\
# OS Configuration
}
Ansible roles for configuring Linux and MacOS environments.
get_app_names() {
grep -E -o -- "^-[[:space:]]+[^[:space:]]+[[:space:]]" <<<"${1}" | cut -d ' ' -f 2-
}
## License
drop() {
eval "${2}=\$(grep -v -E \"^- ${1}\s+.*$\" <<<\"\$${2}\")"
}
[GNU General Public License v3.](https://www.gnu.org/licenses/gpl-3.0.html)
to_md() {
md=""
## Usage
while read -r app; do
disabled=
if [ "${app:0:1}" == '#' ]; then
app=$(cut -d ' ' -f 2- <<<"$app")
disabled=1
fi
\`\`\`
# Create README.md:
$ make doc
md="${md}$(description "$app" "$disabled")\n"
done <<<"$1"
# Configure local OS:
$ make
\`\`\`
echo -e "$md"
}
----
MACOS_APPS=$(get_apps "$MACOS_FILE")
LINUX_APPS=$(get_apps "$LINUX_FILE" | sed -E 's!- [^/]+/!- !')
## Configuration files and scripts
LINUX_APPS_NAMES=($(get_app_names "$LINUX_APPS"))
MACOS_APPS_NAMES=($(get_app_names "$MACOS_APPS"))
- [shellrc](https://code.envrm.info/src/shellrc) - Configuration files for shells (bash, tclsh, etc), X, WM and applications.
- [scripts-linux](https://code.envrm.info/src/scripts-linux) - Various cli scripts.
COMMON_APPS=""
for app in "${MACOS_APPS_NAMES[@]}"; do
alias="$(get_alias $app)"
alias="${alias:-NO_ALIAS}"
----
if [[ "${LINUX_APPS_NAMES[*]}" =~ $app ]] || [[ "${LINUX_APPS_NAMES[*]}" =~ $alias ]]; then
COMMON_APPS="${COMMON_APPS}$(grep -E -- "^-\s+${app}\s+" <<<"$MACOS_APPS")\n"
## MacOS
[[ "${LINUX_APPS_NAMES[*]}" =~ $alias ]] && drop "$alias" LINUX_APPS
### Applications
drop "$app" MACOS_APPS
drop "$app" LINUX_APPS
fi
done
$apps_macos
COMMON_APPS=$(echo -e "$COMMON_APPS")
### Other
apps_common=$(to_md "$COMMON_APPS")
apps_macos=$(to_md "$MACOS_APPS")
apps_linux=$(to_md "$LINUX_APPS")
- [Keyman](https://keyman.com/mac/download) - Input method and screen keyboard for more than 1000 languages.
# ------------------------------------------------------------------------------
"
doc

51
scripts/doc.tpl

@ -0,0 +1,51 @@ @@ -0,0 +1,51 @@
doc() {
cat <<-EOF
# OS Configuration
Ansible roles for configuring Linux and MacOS environments.
## License
[GNU General Public License v3.](https://www.gnu.org/licenses/gpl-3.0.html)
## Usage
\`\`\`
# Create README.md:
$ make doc
# Configure local OS:
$ make
\`\`\`
----
## Configuration files and scripts
- [shellrc](https://code.envrm.info/src/shellrc) - Configuration files for shells (bash, tclsh, etc), X, WM and applications.
- [scripts-linux](https://code.envrm.info/src/scripts-linux) - Various cli scripts.
----
## Common Applications
$apps_common
## Linux
### Applications
$apps_linux
## MacOS
### Applications
$apps_macos
### Other
- [Keyman](https://keyman.com/mac/download) - Input method and screen keyboard for more than 1000 languages.
EOF
}
Loading…
Cancel
Save