Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into 114-fix-exec-wish
Browse files Browse the repository at this point in the history
  • Loading branch information
robinovitch61 committed May 3, 2024
2 parents eba6956 + 02551ed commit 9a2ea2b
Show file tree
Hide file tree
Showing 39 changed files with 710 additions and 147 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Run gofmt
run: if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then exit 1; fi
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: golangci-lint
on:
push:
branches:
- main
- next
pull_request:

permissions:
contents: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.21'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
version: v1.54
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ jobs:
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Run gofmt
run: if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then exit 1; fi
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ vendor
ignore.gif
**/*/my_logs.txt
opt
.vscode
__debug_bin*

11 changes: 11 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
linters:
# Enable specific linter
# https://golangci-lint.run/usage/linters/#enabled-by-default
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- unused
- whitespace
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ An efficient terminal application/TUI for interacting with your [HashiCorp Nomad
- Live tail logs
- Tail global or targeted events
- Exec to interact with running tasks
- Administrative actions (e.g. restart tasks)
- View resource usage stats (memory, CPU)
- See full job or allocation specs
- Save any content to a local file
Expand Down Expand Up @@ -299,4 +300,4 @@ go build # outputs ./wander executable

The [scripts](/scripts) directory contains various development helper scripts.

If the `WANDER_DEBUG` environment variable is set to `true`, the `dev.Debug(s string)` function outputs to `wander.log`.
If the `WANDER_DEBUG` environment variable is set to `true`, the `dev.Debug(s string)` function outputs to `WANDER_DEBUG_PATH` (defaults to `wander.log`).
16 changes: 8 additions & 8 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"errors"
"fmt"
tea "github.com/charmbracelet/bubbletea"
"github.com/robinovitch61/wander/internal/dev"
Expand Down Expand Up @@ -208,7 +209,7 @@ func init() {
rootCmd.PersistentFlags().BoolP(cliLong, rootNameToArg[cliLong].cliShort, rootNameToArg[cliLong].defaultIfBool, rootNameToArg[cliLong].description)

// colors, config or env var only
viper.BindPFlag("", rootCmd.PersistentFlags().Lookup(rootNameToArg["logo-color"].cfgFileEnvVar))
_ = viper.BindPFlag("", rootCmd.PersistentFlags().Lookup(rootNameToArg["logo-color"].cfgFileEnvVar))

for _, cliLong = range []string{
"addr",
Expand Down Expand Up @@ -247,7 +248,7 @@ func init() {
} else {
rootCmd.PersistentFlags().StringP(cliLong, c.cliShort, c.defaultString, c.description)
}
viper.BindPFlag(cliLong, rootCmd.PersistentFlags().Lookup(c.cfgFileEnvVar))
_ = viper.BindPFlag(cliLong, rootCmd.PersistentFlags().Lookup(c.cfgFileEnvVar))
}

// serve
Expand All @@ -265,7 +266,7 @@ func init() {
} else {
serveCmd.PersistentFlags().StringP(cliLong, c.cliShort, c.defaultString, c.description)
}
viper.BindPFlag(cliLong, serveCmd.PersistentFlags().Lookup(c.cfgFileEnvVar))
_ = viper.BindPFlag(cliLong, serveCmd.PersistentFlags().Lookup(c.cfgFileEnvVar))
}

// exec
Expand Down Expand Up @@ -305,9 +306,8 @@ func initConfig(cmd *cobra.Command, nameToArg map[string]arg) error {
if err := viper.ReadInConfig(); err == nil {
fmt.Println("Using config file:", viper.ConfigFileUsed())
} else {
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
// no config file found, that's ok
} else {
var configFileNotFoundError viper.ConfigFileNotFoundError
if !errors.As(err, &configFileNotFoundError) {
fmt.Println(err)
os.Exit(1)
}
Expand All @@ -333,14 +333,14 @@ func bindFlags(cmd *cobra.Command, nameToArg map[string]arg) {
val := v.Get(viperName)
err := cmd.Flags().Set(cliLong, fmt.Sprintf("%v", val))
if err != nil {
fmt.Println(fmt.Sprintf("error setting flag %s: %v", cliLong, err))
fmt.Printf("error setting flag %s: %v\n", cliLong, err)
os.Exit(1)
}
}
})
}

func mainEntrypoint(cmd *cobra.Command, args []string) {
func mainEntrypoint(cmd *cobra.Command, _ []string) {
dev.Debug("~STARTING UP~")
rootOpts := getRootOpts(cmd)
initialModel, options := setup(cmd, rootOpts, "", nil)
Expand Down
5 changes: 1 addition & 4 deletions cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ func validateToken(token string) error {
}

func trueIfTrue(v string) bool {
if strings.ToLower(strings.TrimSpace(v)) == "true" {
return true
}
return false
return strings.ToLower(strings.TrimSpace(v)) == "true"
}

func retrieveLogoColor() string {
Expand Down
Binary file modified img/screenshots/All_Jobs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/screenshots/All_Tasks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/screenshots/Allocation_Statistics.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/screenshots/Exec.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/screenshots/Global_Events.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 12 additions & 12 deletions img/screenshots/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# All Jobs
![](./All_Jobs.png)
# Global Events
![](./Global_Events.png)
# All Tasks
![](./All_Tasks.png)
# Exec
![](./Exec.png)
# Tasks for Job
![](./Tasks_for_Job.png)
# Task Logs
![](./Task_Logs.png)
# Save Any View to Local File
![](./Save_Any_View_to_Local_File.png)
# All Jobs
![](./All_Jobs.png)
# Allocation Statistics
![](./Allocation_Statistics.png)
# Save Any View to Local File
![](./Save_Any_View_to_Local_File.png)
# Task Logs
![](./Task_Logs.png)
# Tasks for Job
![](./Tasks_for_Job.png)
# Exec
![](./Exec.png)
# All Tasks
![](./All_Tasks.png)
Binary file modified img/screenshots/Save_Any_View_to_Local_File.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/screenshots/Task_Logs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/screenshots/Tasks_for_Job.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/wander.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/wander_flow.drawio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion internal/dev/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ import (
)

var debugSet = os.Getenv("WANDER_DEBUG")
var debugPath = os.Getenv("WANDER_DEBUG_PATH")

// dev
func Debug(msg string) {
if debugPath == "" {
debugPath = "wander.log"
}
if debugSet != "" {
f, err := tea.LogToFile("wander.log", "")
f, err := tea.LogToFile(debugPath, "")
if err != nil {
fmt.Println("fatal:", err)
os.Exit(1)
Expand Down
4 changes: 4 additions & 0 deletions internal/fileio/fileio.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import (
"time"
)

type SaveCompleteMessage struct {
FullPath, SuccessMessage, Err string
}

func SaveToFile(saveDialogValue string, fileContent []string) (string, error) {
var path, fileName string

Expand Down
Loading

0 comments on commit 9a2ea2b

Please sign in to comment.