Add help and version info for server binary

This commit is contained in:
2024-05-16 22:22:12 -04:00
parent da044ca59a
commit d8fa62f1ad
4 changed files with 55 additions and 28 deletions
+26 -3
View File
@@ -3,6 +3,7 @@ package main
import (
"fmt"
"github.com/rwinkhart/MUTN/src/backend"
"github.com/rwinkhart/MUTN/src/cli"
"github.com/rwinkhart/MUTN/src/sync"
"os"
"strings"
@@ -11,8 +12,7 @@ import (
func main() {
args := os.Args
if len(args) < 2 {
fmt.Println(backend.AnsiError + "No arguments supplied" + backend.AnsiReset) // TODO add server help menu
os.Exit(0)
helpServer()
}
switch args[1] {
@@ -34,7 +34,30 @@ func main() {
// create the necessary directories for libmuttonserver to function
backend.DirInit()
os.MkdirAll(backend.ConfigDir+backend.PathSeparator+"deletions", 0700)
case "version", "-v":
versionServer()
default:
fmt.Println(backend.AnsiError + "Invalid argument" + backend.AnsiReset) // TODO add server help menu
helpServer()
}
}
func helpServer() {
fmt.Print(cli.AnsiBold + "\nlibmuttonserver | Copyright (c) 2024 Randall Winkhart\n" + backend.AnsiReset + `
This software exists under the MIT license; you may redistribute it under certain conditions.
This program comes with absolutely no warranty; type "libmuttonserver version" for details.
` + cli.AnsiBold + "Usage:" + backend.AnsiReset + ` libmuttonserver <argument>
` + cli.AnsiBold + "Arguments (user):" + backend.AnsiReset + `
help|-h Bring up this menu
version|-v Display version and license information
init Create the necessary directories for libmuttonserver to function` + "\n\n")
os.Exit(0)
}
func versionServer() {
cli.MITLicense()
fmt.Print(cli.AnsiBold + "\n\n libmuttonserver" + backend.AnsiReset + " Version " + backend.LibmuttonVersion + `
Copyright (c) 2024 Randall Winkhart` + "\n\n")
}
+1 -1
View File
@@ -12,6 +12,6 @@ var (
// global constants used across multiple files
const (
ansiBold = "\033[1m"
AnsiBold = "\033[1m"
ansiBlackOnWhite = "\033[38;5;0;48;5;15m"
)
+27 -23
View File
@@ -14,13 +14,13 @@ const (
)
func HelpMain() {
fmt.Print(ansiBold + "\nMUTN | Copyright (c) 2024 Randall Winkhart\n" + backend.AnsiReset + `
fmt.Print(AnsiBold + "\nMUTN | Copyright (c) 2024 Randall Winkhart\n" + backend.AnsiReset + `
This software exists under the MIT license; you may redistribute it under certain conditions.
This program comes with absolutely no warranty; type "mutn version" for details.
` + ansiBold + "Usage:" + backend.AnsiReset + ` mutn [/<entry name> [argument] [option]] | [argument]
` + AnsiBold + "Usage:" + backend.AnsiReset + ` mutn [/<entry name> [argument] [option]] | [argument]
` + ansiBold + "Arguments:" + backend.AnsiReset + `
` + AnsiBold + "Arguments:" + backend.AnsiReset + `
help|-h Bring up this menu
version|-v Display version and license information
init Set up MUTN (generates libmutton.ini)
@@ -32,7 +32,7 @@ This program comes with absolutely no warranty; type "mutn version" for details.
shear Delete an existing entry
sync Manually sync the entry directory
` + ansiBold + "Options:" + backend.AnsiReset + `
` + AnsiBold + "Options:" + backend.AnsiReset + `
copy:
password|-pw|<blank> Copy the password of an entry to your clipboard
username|-u Copy the username of an entry to your clipboard
@@ -52,17 +52,17 @@ This program comes with absolutely no warranty; type "mutn version" for details.
note|-n Add a note entry
folder|-f Add a new folder for entries
` + ansiBold + "Tip 1:" + backend.AnsiReset + ` You can quickly read an entry with "mutn /<entry name>"
` + ansiBold + "Tip 2:" + backend.AnsiReset + ` Type "mutn" (no arguments/options) to view a list of saved entries
` + ansiBold + "Tip 3:" + backend.AnsiReset + ` Provide "add", "edit", "copy", or "gen" as the only argument to receive more specific help
` + ansiBold + "Tip 4:" + backend.AnsiReset + " Using \"add\", \"edit\", or \"copy\" without specifying an option (field) will default to \"password\"\n\n")
` + AnsiBold + "Tip 1:" + backend.AnsiReset + ` You can quickly read an entry with "mutn /<entry name>"
` + AnsiBold + "Tip 2:" + backend.AnsiReset + ` Type "mutn" (no arguments/options) to view a list of saved entries
` + AnsiBold + "Tip 3:" + backend.AnsiReset + ` Provide "add", "edit", "copy", or "gen" as the only argument to receive more specific help
` + AnsiBold + "Tip 4:" + backend.AnsiReset + " Using \"add\", \"edit\", or \"copy\" without specifying an option (field) will default to \"password\"\n\n")
os.Exit(0)
}
func HelpAdd() {
fmt.Print(ansiBold + "\nUsage:" + backend.AnsiReset + ` mutn /<entry name> add <option>
fmt.Print(AnsiBold + "\nUsage:" + backend.AnsiReset + ` mutn /<entry name> add <option>
` + ansiBold + "Options:" + backend.AnsiReset + `
` + AnsiBold + "Options:" + backend.AnsiReset + `
add:
password|-pw|<blank> Add a password entry
note|-n Add a note entry
@@ -71,9 +71,9 @@ func HelpAdd() {
}
func HelpEdit() {
fmt.Print(ansiBold + "\nUsage:" + backend.AnsiReset + ` mutn /<entry name> edit <option>
fmt.Print(AnsiBold + "\nUsage:" + backend.AnsiReset + ` mutn /<entry name> edit <option>
` + ansiBold + "Options:" + backend.AnsiReset + `
` + AnsiBold + "Options:" + backend.AnsiReset + `
edit:
password|-pw|<blank> Change the password of an entry
username|-u Change the username of an entry
@@ -84,9 +84,9 @@ func HelpEdit() {
}
func HelpCopy() {
fmt.Print(ansiBold + "\nUsage:" + backend.AnsiReset + ` mutn /<entry name> copy <option>
fmt.Print(AnsiBold + "\nUsage:" + backend.AnsiReset + ` mutn /<entry name> copy <option>
` + ansiBold + "Options:" + backend.AnsiReset + `
` + AnsiBold + "Options:" + backend.AnsiReset + `
copy:
password|-pw|<blank> Copy the password in an entry to your clipboard
username|-u Copy the username in an entry to your clipboard
@@ -97,18 +97,18 @@ func HelpCopy() {
}
func HelpGen() {
fmt.Print(ansiBold + "\nUsage:" + backend.AnsiReset + ` mutn /<entry name> gen [option]
fmt.Print(AnsiBold + "\nUsage:" + backend.AnsiReset + ` mutn /<entry name> gen [option]
` + ansiBold + "Options:" + backend.AnsiReset + `
` + AnsiBold + "Options:" + backend.AnsiReset + `
gen:
update|-u Generate a password for an existing entry
` + ansiBold + "Tip:" + backend.AnsiReset + " If no options are provided, a new password entry is generated\n\n")
` + AnsiBold + "Tip:" + backend.AnsiReset + " If no options are provided, a new password entry is generated\n\n")
os.Exit(0)
}
func Version() {
fmt.Print(ansiBold + "\n MIT License" + backend.AnsiReset + `
func MITLicense() {
fmt.Print(AnsiBold + "\n MIT License" + backend.AnsiReset + `
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
@@ -132,9 +132,13 @@ ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
OR OTHER DEALINGS IN THE SOFTWARE.` +
"\n\n---------------------------------------------------------" +
"\n\n MUTN is a simple, self-hosted,\n SSH-synchronized password manager based on libmutton\n\n" +
OR OTHER DEALINGS IN THE SOFTWARE.` + "\n\n---------------------------------------------------------")
// do not exit, as this is meant to be followed by other information
}
func Version() {
MITLicense()
fmt.Print("\n\n MUTN is a simple, self-hosted,\n SSH-synchronized password manager based on libmutton\n\n" +
" .. ..\n" +
" /()\\''.''. " + ansiVersionMeat + "♥♥♥♥" + backend.AnsiReset + " .''.''/()\\ _)\n" +
" _. : * " + ansiVersionMeat + "♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥" + backend.AnsiReset + " * : <[◎]|_|=\n" +
@@ -142,7 +146,7 @@ ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
" ◎-◎ // \\\\ " + ansiVersionMeat + "♥♥♥♥♥♥♥♥♥" + backend.AnsiReset + " // \\\\ /|\\\n" +
ansiVersionOutline + "<><><><><><><><><><><><><><>-<><><><><><><><><><><><><><>\n" +
"\\" + ansiBlackOnWhite + " " + backend.AnsiReset + ansiVersionOutline + "/\n" +
"\\" + ansiBlackOnWhite + " MUTN Version 0.2.X " + backend.AnsiReset + ansiVersionOutline + "/\n" +
"\\" + ansiBlackOnWhite + " MUTN Version " + backend.LibmuttonVersion + " " + backend.AnsiReset + ansiVersionOutline + "/\n" +
"\\" + ansiBlackOnWhite + " The Placeholder Update " + backend.AnsiReset + ansiVersionOutline + "/\n" +
"\\" + ansiBlackOnWhite + " " + backend.AnsiReset + ansiVersionOutline + "/\n" +
"\\" + ansiBlackOnWhite + " Copyright (c) 2024 Randall Winkhart " + backend.AnsiReset + ansiVersionOutline + "/\n" +
+1 -1
View File
@@ -77,7 +77,7 @@ func writeEntryCLI(targetLocation string, unencryptedEntry []string, hidePasswor
// write the entry to the target location
backend.WriteEntry(targetLocation, unencryptedEntry)
// preview the entry
fmt.Println(ansiBold + "\nEntry Preview:" + backend.AnsiReset)
fmt.Println(AnsiBold + "\nEntry Preview:" + backend.AnsiReset)
EntryReader(unencryptedEntry, hidePassword, true)
} else {
fmt.Println(backend.AnsiError + "No data supplied for entry" + backend.AnsiReset)