Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
timopruesse committed Mar 4, 2023
1 parent 186c5e7 commit 3f7c933
Show file tree
Hide file tree
Showing 16 changed files with 846 additions and 139 deletions.
257 changes: 248 additions & 9 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ num_cpus = "1"
rand = "0.8"
ergo_fs = "0.2"
yaml-rust = "0.4"
serde_json = "1.0"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
symlink = "0.1"
git_commands = "0.2"
clap = { version = "4", features = ["derive", "wrap_help"] }
ansi_term = "0.12"
dialoguer = "0.10"
regex = "1.7.1"
chrono = "0.4"
7 changes: 2 additions & 5 deletions TODOS.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# TODOs

- save timestamps (at least for install), so the next install only runs new tasks
only update/uninstall should affect already run tasks

---

- list skipped tasks (additionally to the errors)
- return Error struct instead of String from tasks (that can indicate if it's a hard failure or not)
- Fix homebrew/tap setup
- Add option to run `copy` and `symlink` as root user (needed to move/link some system files)

Expand Down
70 changes: 40 additions & 30 deletions completions/_machine_setup
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ _machine_setup() {
'--config=[path to the config file]:CONFIG: ' \
'-t+[run a single task]:TASK: ' \
'--task=[run a single task]:TASK: ' \
'-l+[Set log level]:LEVEL: ' \
'--level=[Set log level]:LEVEL: ' \
'-s[Select a task to run]' \
'--select[Select a task to run]' \
'-d[Add debug information]' \
'--debug[Add debug information]' \
'-l+[set log level]:LEVEL: ' \
'--level=[set log level]:LEVEL: ' \
'-s[select a task to run]' \
'--select[select a task to run]' \
'-d[add debug information]' \
'--debug[add debug information]' \
'-f[force installation/uninstallation]' \
'--force[force installation/uninstallation]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
Expand All @@ -44,12 +46,14 @@ _arguments "${_arguments_options[@]}" \
'--config=[path to the config file]:CONFIG: ' \
'-t+[run a single task]:TASK: ' \
'--task=[run a single task]:TASK: ' \
'-l+[Set log level]:LEVEL: ' \
'--level=[Set log level]:LEVEL: ' \
'-s[Select a task to run]' \
'--select[Select a task to run]' \
'-d[Add debug information]' \
'--debug[Add debug information]' \
'-l+[set log level]:LEVEL: ' \
'--level=[set log level]:LEVEL: ' \
'-s[select a task to run]' \
'--select[select a task to run]' \
'-d[add debug information]' \
'--debug[add debug information]' \
'-f[force installation/uninstallation]' \
'--force[force installation/uninstallation]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
Expand All @@ -62,12 +66,14 @@ _arguments "${_arguments_options[@]}" \
'--config=[path to the config file]:CONFIG: ' \
'-t+[run a single task]:TASK: ' \
'--task=[run a single task]:TASK: ' \
'-l+[Set log level]:LEVEL: ' \
'--level=[Set log level]:LEVEL: ' \
'-s[Select a task to run]' \
'--select[Select a task to run]' \
'-d[Add debug information]' \
'--debug[Add debug information]' \
'-l+[set log level]:LEVEL: ' \
'--level=[set log level]:LEVEL: ' \
'-s[select a task to run]' \
'--select[select a task to run]' \
'-d[add debug information]' \
'--debug[add debug information]' \
'-f[force installation/uninstallation]' \
'--force[force installation/uninstallation]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
Expand All @@ -80,12 +86,14 @@ _arguments "${_arguments_options[@]}" \
'--config=[path to the config file]:CONFIG: ' \
'-t+[run a single task]:TASK: ' \
'--task=[run a single task]:TASK: ' \
'-l+[Set log level]:LEVEL: ' \
'--level=[Set log level]:LEVEL: ' \
'-s[Select a task to run]' \
'--select[Select a task to run]' \
'-d[Add debug information]' \
'--debug[Add debug information]' \
'-l+[set log level]:LEVEL: ' \
'--level=[set log level]:LEVEL: ' \
'-s[select a task to run]' \
'--select[select a task to run]' \
'-d[add debug information]' \
'--debug[add debug information]' \
'-f[force installation/uninstallation]' \
'--force[force installation/uninstallation]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
Expand All @@ -98,12 +106,14 @@ _arguments "${_arguments_options[@]}" \
'--config=[path to the config file]:CONFIG: ' \
'-t+[run a single task]:TASK: ' \
'--task=[run a single task]:TASK: ' \
'-l+[Set log level]:LEVEL: ' \
'--level=[Set log level]:LEVEL: ' \
'-s[Select a task to run]' \
'--select[Select a task to run]' \
'-d[Add debug information]' \
'--debug[Add debug information]' \
'-l+[set log level]:LEVEL: ' \
'--level=[set log level]:LEVEL: ' \
'-s[select a task to run]' \
'--select[select a task to run]' \
'-d[add debug information]' \
'--debug[add debug information]' \
'-f[force installation/uninstallation]' \
'--force[force installation/uninstallation]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
Expand Down
70 changes: 40 additions & 30 deletions completions/_machine_setup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ Register-ArgumentCompleter -Native -CommandName 'machine_setup' -ScriptBlock {
[CompletionResult]::new('--config', 'config', [CompletionResultType]::ParameterName, 'path to the config file')
[CompletionResult]::new('-t', 't', [CompletionResultType]::ParameterName, 'run a single task')
[CompletionResult]::new('--task', 'task', [CompletionResultType]::ParameterName, 'run a single task')
[CompletionResult]::new('-l', 'l', [CompletionResultType]::ParameterName, 'Set log level')
[CompletionResult]::new('--level', 'level', [CompletionResultType]::ParameterName, 'Set log level')
[CompletionResult]::new('-s', 's', [CompletionResultType]::ParameterName, 'Select a task to run')
[CompletionResult]::new('--select', 'select', [CompletionResultType]::ParameterName, 'Select a task to run')
[CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'Add debug information')
[CompletionResult]::new('--debug', 'debug', [CompletionResultType]::ParameterName, 'Add debug information')
[CompletionResult]::new('-l', 'l', [CompletionResultType]::ParameterName, 'set log level')
[CompletionResult]::new('--level', 'level', [CompletionResultType]::ParameterName, 'set log level')
[CompletionResult]::new('-s', 's', [CompletionResultType]::ParameterName, 'select a task to run')
[CompletionResult]::new('--select', 'select', [CompletionResultType]::ParameterName, 'select a task to run')
[CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'add debug information')
[CompletionResult]::new('--debug', 'debug', [CompletionResultType]::ParameterName, 'add debug information')
[CompletionResult]::new('-f', 'f', [CompletionResultType]::ParameterName, 'force installation/uninstallation')
[CompletionResult]::new('--force', 'force', [CompletionResultType]::ParameterName, 'force installation/uninstallation')
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version')
Expand All @@ -47,12 +49,14 @@ Register-ArgumentCompleter -Native -CommandName 'machine_setup' -ScriptBlock {
[CompletionResult]::new('--config', 'config', [CompletionResultType]::ParameterName, 'path to the config file')
[CompletionResult]::new('-t', 't', [CompletionResultType]::ParameterName, 'run a single task')
[CompletionResult]::new('--task', 'task', [CompletionResultType]::ParameterName, 'run a single task')
[CompletionResult]::new('-l', 'l', [CompletionResultType]::ParameterName, 'Set log level')
[CompletionResult]::new('--level', 'level', [CompletionResultType]::ParameterName, 'Set log level')
[CompletionResult]::new('-s', 's', [CompletionResultType]::ParameterName, 'Select a task to run')
[CompletionResult]::new('--select', 'select', [CompletionResultType]::ParameterName, 'Select a task to run')
[CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'Add debug information')
[CompletionResult]::new('--debug', 'debug', [CompletionResultType]::ParameterName, 'Add debug information')
[CompletionResult]::new('-l', 'l', [CompletionResultType]::ParameterName, 'set log level')
[CompletionResult]::new('--level', 'level', [CompletionResultType]::ParameterName, 'set log level')
[CompletionResult]::new('-s', 's', [CompletionResultType]::ParameterName, 'select a task to run')
[CompletionResult]::new('--select', 'select', [CompletionResultType]::ParameterName, 'select a task to run')
[CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'add debug information')
[CompletionResult]::new('--debug', 'debug', [CompletionResultType]::ParameterName, 'add debug information')
[CompletionResult]::new('-f', 'f', [CompletionResultType]::ParameterName, 'force installation/uninstallation')
[CompletionResult]::new('--force', 'force', [CompletionResultType]::ParameterName, 'force installation/uninstallation')
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version')
Expand All @@ -64,12 +68,14 @@ Register-ArgumentCompleter -Native -CommandName 'machine_setup' -ScriptBlock {
[CompletionResult]::new('--config', 'config', [CompletionResultType]::ParameterName, 'path to the config file')
[CompletionResult]::new('-t', 't', [CompletionResultType]::ParameterName, 'run a single task')
[CompletionResult]::new('--task', 'task', [CompletionResultType]::ParameterName, 'run a single task')
[CompletionResult]::new('-l', 'l', [CompletionResultType]::ParameterName, 'Set log level')
[CompletionResult]::new('--level', 'level', [CompletionResultType]::ParameterName, 'Set log level')
[CompletionResult]::new('-s', 's', [CompletionResultType]::ParameterName, 'Select a task to run')
[CompletionResult]::new('--select', 'select', [CompletionResultType]::ParameterName, 'Select a task to run')
[CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'Add debug information')
[CompletionResult]::new('--debug', 'debug', [CompletionResultType]::ParameterName, 'Add debug information')
[CompletionResult]::new('-l', 'l', [CompletionResultType]::ParameterName, 'set log level')
[CompletionResult]::new('--level', 'level', [CompletionResultType]::ParameterName, 'set log level')
[CompletionResult]::new('-s', 's', [CompletionResultType]::ParameterName, 'select a task to run')
[CompletionResult]::new('--select', 'select', [CompletionResultType]::ParameterName, 'select a task to run')
[CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'add debug information')
[CompletionResult]::new('--debug', 'debug', [CompletionResultType]::ParameterName, 'add debug information')
[CompletionResult]::new('-f', 'f', [CompletionResultType]::ParameterName, 'force installation/uninstallation')
[CompletionResult]::new('--force', 'force', [CompletionResultType]::ParameterName, 'force installation/uninstallation')
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version')
Expand All @@ -81,12 +87,14 @@ Register-ArgumentCompleter -Native -CommandName 'machine_setup' -ScriptBlock {
[CompletionResult]::new('--config', 'config', [CompletionResultType]::ParameterName, 'path to the config file')
[CompletionResult]::new('-t', 't', [CompletionResultType]::ParameterName, 'run a single task')
[CompletionResult]::new('--task', 'task', [CompletionResultType]::ParameterName, 'run a single task')
[CompletionResult]::new('-l', 'l', [CompletionResultType]::ParameterName, 'Set log level')
[CompletionResult]::new('--level', 'level', [CompletionResultType]::ParameterName, 'Set log level')
[CompletionResult]::new('-s', 's', [CompletionResultType]::ParameterName, 'Select a task to run')
[CompletionResult]::new('--select', 'select', [CompletionResultType]::ParameterName, 'Select a task to run')
[CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'Add debug information')
[CompletionResult]::new('--debug', 'debug', [CompletionResultType]::ParameterName, 'Add debug information')
[CompletionResult]::new('-l', 'l', [CompletionResultType]::ParameterName, 'set log level')
[CompletionResult]::new('--level', 'level', [CompletionResultType]::ParameterName, 'set log level')
[CompletionResult]::new('-s', 's', [CompletionResultType]::ParameterName, 'select a task to run')
[CompletionResult]::new('--select', 'select', [CompletionResultType]::ParameterName, 'select a task to run')
[CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'add debug information')
[CompletionResult]::new('--debug', 'debug', [CompletionResultType]::ParameterName, 'add debug information')
[CompletionResult]::new('-f', 'f', [CompletionResultType]::ParameterName, 'force installation/uninstallation')
[CompletionResult]::new('--force', 'force', [CompletionResultType]::ParameterName, 'force installation/uninstallation')
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version')
Expand All @@ -98,12 +106,14 @@ Register-ArgumentCompleter -Native -CommandName 'machine_setup' -ScriptBlock {
[CompletionResult]::new('--config', 'config', [CompletionResultType]::ParameterName, 'path to the config file')
[CompletionResult]::new('-t', 't', [CompletionResultType]::ParameterName, 'run a single task')
[CompletionResult]::new('--task', 'task', [CompletionResultType]::ParameterName, 'run a single task')
[CompletionResult]::new('-l', 'l', [CompletionResultType]::ParameterName, 'Set log level')
[CompletionResult]::new('--level', 'level', [CompletionResultType]::ParameterName, 'Set log level')
[CompletionResult]::new('-s', 's', [CompletionResultType]::ParameterName, 'Select a task to run')
[CompletionResult]::new('--select', 'select', [CompletionResultType]::ParameterName, 'Select a task to run')
[CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'Add debug information')
[CompletionResult]::new('--debug', 'debug', [CompletionResultType]::ParameterName, 'Add debug information')
[CompletionResult]::new('-l', 'l', [CompletionResultType]::ParameterName, 'set log level')
[CompletionResult]::new('--level', 'level', [CompletionResultType]::ParameterName, 'set log level')
[CompletionResult]::new('-s', 's', [CompletionResultType]::ParameterName, 'select a task to run')
[CompletionResult]::new('--select', 'select', [CompletionResultType]::ParameterName, 'select a task to run')
[CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'add debug information')
[CompletionResult]::new('--debug', 'debug', [CompletionResultType]::ParameterName, 'add debug information')
[CompletionResult]::new('-f', 'f', [CompletionResultType]::ParameterName, 'force installation/uninstallation')
[CompletionResult]::new('--force', 'force', [CompletionResultType]::ParameterName, 'force installation/uninstallation')
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version')
Expand Down
10 changes: 5 additions & 5 deletions completions/machine_setup.bash
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ _machine_setup() {

case "${cmd}" in
machine_setup)
opts="-c -t -s -d -l -h -V --config --task --select --debug --level --help --version install update uninstall list help"
opts="-c -t -s -d -l -f -h -V --config --task --select --debug --level --force --help --version install update uninstall list help"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
Expand Down Expand Up @@ -171,7 +171,7 @@ _machine_setup() {
return 0
;;
machine_setup__install)
opts="-c -t -s -d -l -h -V --config --task --select --debug --level --help --version"
opts="-c -t -s -d -l -f -h -V --config --task --select --debug --level --force --help --version"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
Expand Down Expand Up @@ -209,7 +209,7 @@ _machine_setup() {
return 0
;;
machine_setup__list)
opts="-c -t -s -d -l -h -V --config --task --select --debug --level --help --version"
opts="-c -t -s -d -l -f -h -V --config --task --select --debug --level --force --help --version"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
Expand Down Expand Up @@ -247,7 +247,7 @@ _machine_setup() {
return 0
;;
machine_setup__uninstall)
opts="-c -t -s -d -l -h -V --config --task --select --debug --level --help --version"
opts="-c -t -s -d -l -f -h -V --config --task --select --debug --level --force --help --version"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
Expand Down Expand Up @@ -285,7 +285,7 @@ _machine_setup() {
return 0
;;
machine_setup__update)
opts="-c -t -s -d -l -h -V --config --task --select --debug --level --help --version"
opts="-c -t -s -d -l -f -h -V --config --task --select --debug --level --force --help --version"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
Expand Down
Loading

0 comments on commit 3f7c933

Please sign in to comment.