Skip to content

Commit

Permalink
Replace a simple bash script with golang
Browse files Browse the repository at this point in the history
  • Loading branch information
kachick committed Jul 27, 2023
1 parent f6da56e commit 23b1c25
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"[fish]": {
"editor.defaultFormatter": "bmalehorn.vscode-fish"
},
"[go]": {
"editor.defaultFormatter": "golang.go"
},
"nix.serverPath": "nil",
"nix.enableLanguageServer": true,
"nix.serverSettings": {
Expand Down
6 changes: 5 additions & 1 deletion Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ command = './scripts/fmt.bash'
alias = "lint"

[tasks.deps]
command = './scripts/print-deps.bash'
command = 'go'
args = [
'run',
'./cmd/print-deps',
]
32 changes: 32 additions & 0 deletions cmd/print-deps/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package main

import (
"log"
"os/exec"
"strings"
)

func main() {
cmds := []struct {
path string
args []string
}{
{"go", []string{"version"}},
{"makers", []string{"--version"}},
{"nix", []string{"--version"}},
{"dprint", []string{"--version"}},
{"shellcheck", []string{"--version"}},
{"shfmt", []string{"--version"}},
{"fd", []string{"--version"}},
{"typos", []string{"--version"}},
{"gitleaks", []string{"version"}},
}

for _, cmd := range cmds {
output, err := exec.Command(cmd.path, cmd.args...).Output()
log.Printf("%s %s\n%s\n", cmd.path, strings.Join(cmd.args, " "), output)
if err != nil {
log.Fatalln(err)
}
}
}
1 change: 1 addition & 0 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ pkgs.mkShell {
pkgs.coreutils
pkgs.fd
pkgs.typos
pkgs.go_1_20
];
}
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module print-deps

go 1.20
17 changes: 0 additions & 17 deletions scripts/print-deps.bash

This file was deleted.

0 comments on commit 23b1c25

Please sign in to comment.