This repository has been archived by the owner on Sep 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add
abdfnx/gosh
module, create pkg/info
package
- Loading branch information
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |