Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Commit

Permalink
add abdfnx/gosh module, create pkg/info package
Browse files Browse the repository at this point in the history
  • Loading branch information
abdfnx committed Mar 9, 2022
1 parent ffd7e64 commit 5956780
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.17
require (
github.com/AlecAivazis/survey/v2 v2.3.2
github.com/abdfnx/bubbles v0.10.7
github.com/abdfnx/gosh v0.3.8
github.com/abdfnx/looker v0.1.0
github.com/abdfnx/resto v0.1.6
github.com/abdfnx/tran v0.1.3
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ github.com/abdfnx/git_config v0.0.32/go.mod h1:ZUF8HzpOLtnx4rbG3r4TeutEOfE1ys+Qd
github.com/abdfnx/git_config v0.0.33/go.mod h1:issGEj0pMwM6KQGClUVEJmpD39EFAhtj1EgcTDW3J1o=
github.com/abdfnx/git_config v0.0.34/go.mod h1:Unb6Ey03cySt9pCobmmIsPl0vkNiZb0ztdDpTYrRazM=
github.com/abdfnx/gosh v0.3.5/go.mod h1:bho3zdOB7bNUOZDeI5+CSjoiF+MHmzHWqHHDAQiCq1c=
github.com/abdfnx/gosh v0.3.8 h1:K60mFTwvhXrwd5JtROBjhAWE0OJOisFMkLvLB59txLk=
github.com/abdfnx/gosh v0.3.8/go.mod h1:bho3zdOB7bNUOZDeI5+CSjoiF+MHmzHWqHHDAQiCq1c=
github.com/abdfnx/looker v0.1.0 h1:tMN7E0wKIgbydAPPQ1RkppJ1bGHn+B+y9PZy7mwa+3U=
github.com/abdfnx/looker v0.1.0/go.mod h1:QVfPHnredPBUg4R+MtEkZbMBbqrgtoaj0JHO3KYkvyE=
github.com/abdfnx/resto v0.1.6 h1:yOM9O9bpMP4lb2ox0U7/gcFXO78P5eUZBxWuKrfdrFA=
Expand Down
48 changes: 48 additions & 0 deletions pkg/info/info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package info

import (
"fmt"

"github.com/abdfnx/gosh"
"github.com/scmn-dev/secman/api"
"github.com/charmbracelet/glamour"
"github.com/scmn-dev/secman/internal/config"
)

func Info(version string) {
err, smcVersion, _ := gosh.RunOutput("sc -v")
user := "`" + config.Config("config.name") + "`"

if user == "``" {
user = "`No User`"
}

// remove the last line
smcVersion = smcVersion[:len(smcVersion)-1]

if err != nil {
fmt.Println("could not get sc version")
return
}

out1 := fmt.Sprintf(`# Secman CLI
* Version: %s
* Secman Core Version: %s
* Secman Core CLI Version: %s
Current User: %s
> Made with ❤️ by [secman](https://github.com/scmn-dev)`, version, api.GetLatestCore(), smcVersion, user)

cli, err := glamour.Render(out1, "dark")

if err != nil {
fmt.Println("could not render info")
return
}

cli = cli[:len(cli)-1]

fmt.Print(cli)
}

0 comments on commit 5956780

Please sign in to comment.