1
0
Fork 0
mirror of synced 2024-11-26 17:25:35 -05:00

[meta] Move zmanage to function in init.zsh

and delete the meta module altogether.

Also refactor `tools/zim_issue` to use `tools/zim_info`, use local
variables, and print the output directly without the need of the
intermediate `issue_md` array.

Closes #218
This commit is contained in:
Eric Nielsen 2017-10-23 09:33:57 -05:00
parent a8244a555a
commit e0a7c679e0
5 changed files with 55 additions and 91 deletions

View file

@ -39,3 +39,43 @@ fi
fi
done
}
zmanage() {
local usage="zmanage [action]
Actions:
update Fetch and merge upstream zim commits if possible
info Print zim and system info
issue Create a template for reporting an issue
clean-cache Clean the zim cache
build-cache Rebuild the zim cache
remove *experimental* Remove zim as best we can
reset Reset zim to the latest commit
debug Invoke the trace-zim script which produces logs
help Print this usage message"
if (( ${#} != 1 )); then
print ${usage}
return 1
fi
case ${1} in
update) zsh ${ZIM_HOME}/tools/zim_update
;;
info) zsh ${ZIM_HOME}/tools/zim_info
;;
issue) zsh ${ZIM_HOME}/tools/zim_issue
;;
clean-cache) source ${ZIM_HOME}/tools/zim_clean_cache && print 'Cache cleaned'
;;
build-cache) source ${ZIM_HOME}/tools/zim_build_cache && print 'Cache rebuilt'
;;
remove) zsh ${ZIM_HOME}/tools/zim_remove
;;
reset) zsh ${ZIM_HOME}/tools/zim_reset
;;
debug) zsh ${ZIM_HOME}/modules/debug/functions/trace-zim
;;
*) print ${usage}; return 1
;;
esac
}

View file

@ -1,21 +0,0 @@
Meta
====
Provides aliases and functions for management of the zim framework, specifically `zmanage`
Usage
-----
`zmanage [arg]`
| Action | Description |
| ----------- | --------------------------------------------------- |
| update | Fetches and merges upstream zim commits if possible |
| info | Prints zim and system info |
| issue | Create a template for reporting an issue |
| clean-cache | Clean the zim cache |
| build-cache | Rebuild the zim cache |
| remove | *experimental* Remove zim as best we can |
| reset | Reset zim to the latest commit |
| help | Print this usage message |
| debug | Invokes the trace-zim script which produces logs |

View file

@ -1,40 +0,0 @@
local usage="${0} [action]
Actions:
| update | Fetches and merges upstream zim commits if possible |
| info | Prints zim and system info |
| issue | Create a template for reporting an issue |
| clean-cache | Clean the zim cache |
| build-cache | Rebuild the zim cache |
| remove | *experimental* Remove zim as best we can |
| reset | Reset zim to the latest commit |
| help | Print this usage message |
| debug | Invokes the trace-zim script which produces logs |"
if (( ${#} != 1 )); then
print ${usage}
return 1
fi
local tools
tools="${ZIM_HOME}/tools"
case ${1} in
update) zsh ${tools}/zim_update
;;
info) zsh ${tools}/zim_info
;;
issue) zsh ${tools}/zim_issue
;;
clean-cache) source ${tools}/zim_clean_cache && print 'Cleaned cache'
;;
build-cache) source ${tools}/zim_build_cache && print 'Rebuilt cache'
;;
remove) zsh ${tools}/zim_remove
;;
reset) zsh ${tools}/zim_reset
;;
debug) zsh ${ZIM_HOME}/modules/debug/functions/trace-zim
;;
*) print ${usage}
;;
esac

View file

@ -11,7 +11,7 @@
# Select what modules you would like enabled.
# The second line of modules may depend on options set by modules in the first
# line. These dependencies are noted on the respective module's README.md.
zmodules=(directory environment git git-info history input utility meta custom \
zmodules=(directory environment git git-info history input utility custom \
syntax-highlighting history-substring-search prompt completion)

View file

@ -27,41 +27,26 @@ fi
cd ${ZIM_HOME}
# collect sys info
git_dirty=$(command git status --porcelain 2>/dev/null | tail -n1)
git_ref=$(command git rev-parse --short HEAD)
zsh_version=$(zsh --version)
operating_sys=$(uname -a)
local git_dirty=$(command git status --porcelain 2>/dev/null | tail -n1)
local zim_info=$(zsh tools/zim_info)
print "Environment Info
----------------
${zim_info}
Description
-----------
${user_desc}
# we're going to template and build the issue here (as an array for convenience)
Steps to Reproduce
------------------
${user_reproduce}
issue_md=("Environment Info"
"----------------"
"- Zim commit ref: ${git_ref}"
"- Zsh version: ${zsh_version}"
"- Operating System Info: ${operating_sys}"
""
"Description"
"-----------"
"${user_desc}"
""
"Steps to Reproduce"
"------------------"
"${user_reproduce}"
""
"Images or other Information"
"---------------------------"
""
)
Images or other Information
---------------------------
"
# print the output:
# hack: we need to iterate over the elements to capture the blank spaces (to print newlines)
for (( i=0; i < ${#issue_md[@]}; i++ )); do
printf '%s\n' ${issue_md[i]}
done
# if we have a dirty git, report it
if [[ -n ${git_dirty} ]]; then
print "${ZIM_HOME} has a dirty git working tree."