mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-08-28 04:46:41 -04:00
Add help and version info for server binary
This commit is contained in:
+26
-3
@@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/rwinkhart/MUTN/src/backend"
|
"github.com/rwinkhart/MUTN/src/backend"
|
||||||
|
"github.com/rwinkhart/MUTN/src/cli"
|
||||||
"github.com/rwinkhart/MUTN/src/sync"
|
"github.com/rwinkhart/MUTN/src/sync"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -11,8 +12,7 @@ import (
|
|||||||
func main() {
|
func main() {
|
||||||
args := os.Args
|
args := os.Args
|
||||||
if len(args) < 2 {
|
if len(args) < 2 {
|
||||||
fmt.Println(backend.AnsiError + "No arguments supplied" + backend.AnsiReset) // TODO add server help menu
|
helpServer()
|
||||||
os.Exit(0)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch args[1] {
|
switch args[1] {
|
||||||
@@ -34,7 +34,30 @@ func main() {
|
|||||||
// create the necessary directories for libmuttonserver to function
|
// create the necessary directories for libmuttonserver to function
|
||||||
backend.DirInit()
|
backend.DirInit()
|
||||||
os.MkdirAll(backend.ConfigDir+backend.PathSeparator+"deletions", 0700)
|
os.MkdirAll(backend.ConfigDir+backend.PathSeparator+"deletions", 0700)
|
||||||
|
case "version", "-v":
|
||||||
|
versionServer()
|
||||||
default:
|
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")
|
||||||
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ var (
|
|||||||
|
|
||||||
// global constants used across multiple files
|
// global constants used across multiple files
|
||||||
const (
|
const (
|
||||||
AnsiError = "\033[38;5;9m"
|
AnsiError = "\033[38;5;9m"
|
||||||
AnsiReset = "\033[0m"
|
AnsiReset = "\033[0m"
|
||||||
|
LibmuttonVersion = "0.2.X"
|
||||||
)
|
)
|
||||||
|
|||||||
+1
-1
@@ -12,6 +12,6 @@ var (
|
|||||||
|
|
||||||
// global constants used across multiple files
|
// global constants used across multiple files
|
||||||
const (
|
const (
|
||||||
ansiBold = "\033[1m"
|
AnsiBold = "\033[1m"
|
||||||
ansiBlackOnWhite = "\033[38;5;0;48;5;15m"
|
ansiBlackOnWhite = "\033[38;5;0;48;5;15m"
|
||||||
)
|
)
|
||||||
|
|||||||
+27
-23
@@ -14,13 +14,13 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func HelpMain() {
|
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 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.
|
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
|
help|-h Bring up this menu
|
||||||
version|-v Display version and license information
|
version|-v Display version and license information
|
||||||
init Set up MUTN (generates libmutton.ini)
|
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
|
shear Delete an existing entry
|
||||||
sync Manually sync the entry directory
|
sync Manually sync the entry directory
|
||||||
|
|
||||||
` + ansiBold + "Options:" + backend.AnsiReset + `
|
` + AnsiBold + "Options:" + backend.AnsiReset + `
|
||||||
copy:
|
copy:
|
||||||
password|-pw|<blank> Copy the password of an entry to your clipboard
|
password|-pw|<blank> Copy the password of an entry to your clipboard
|
||||||
username|-u Copy the username 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
|
note|-n Add a note entry
|
||||||
folder|-f Add a new folder for entries
|
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 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 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 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 4:" + backend.AnsiReset + " Using \"add\", \"edit\", or \"copy\" without specifying an option (field) will default to \"password\"\n\n")
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func HelpAdd() {
|
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:
|
add:
|
||||||
password|-pw|<blank> Add a password entry
|
password|-pw|<blank> Add a password entry
|
||||||
note|-n Add a note entry
|
note|-n Add a note entry
|
||||||
@@ -71,9 +71,9 @@ func HelpAdd() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func HelpEdit() {
|
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:
|
edit:
|
||||||
password|-pw|<blank> Change the password of an entry
|
password|-pw|<blank> Change the password of an entry
|
||||||
username|-u Change the username of an entry
|
username|-u Change the username of an entry
|
||||||
@@ -84,9 +84,9 @@ func HelpEdit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func HelpCopy() {
|
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:
|
copy:
|
||||||
password|-pw|<blank> Copy the password in an entry to your clipboard
|
password|-pw|<blank> Copy the password in an entry to your clipboard
|
||||||
username|-u Copy the username 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() {
|
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:
|
gen:
|
||||||
update|-u Generate a password for an existing entry
|
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)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Version() {
|
func MITLicense() {
|
||||||
fmt.Print(ansiBold + "\n MIT License" + backend.AnsiReset + `
|
fmt.Print(AnsiBold + "\n MIT License" + backend.AnsiReset + `
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any
|
Permission is hereby granted, free of charge, to any
|
||||||
person obtaining a copy of this software and associated
|
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
|
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||||
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
||||||
OR OTHER DEALINGS IN THE SOFTWARE.` +
|
OR OTHER DEALINGS IN THE SOFTWARE.` + "\n\n---------------------------------------------------------")
|
||||||
"\n\n---------------------------------------------------------" +
|
// do not exit, as this is meant to be followed by other information
|
||||||
"\n\n MUTN is a simple, self-hosted,\n SSH-synchronized password manager based on libmutton\n\n" +
|
}
|
||||||
|
|
||||||
|
func Version() {
|
||||||
|
MITLicense()
|
||||||
|
fmt.Print("\n\n MUTN is a simple, self-hosted,\n SSH-synchronized password manager based on libmutton\n\n" +
|
||||||
" .. ..\n" +
|
" .. ..\n" +
|
||||||
" /()\\''.''. " + ansiVersionMeat + "♥♥♥♥" + backend.AnsiReset + " .''.''/()\\ _)\n" +
|
" /()\\''.''. " + ansiVersionMeat + "♥♥♥♥" + backend.AnsiReset + " .''.''/()\\ _)\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" +
|
" ◎-◎ // \\\\ " + ansiVersionMeat + "♥♥♥♥♥♥♥♥♥" + backend.AnsiReset + " // \\\\ /|\\\n" +
|
||||||
ansiVersionOutline + "<><><><><><><><><><><><><><>-<><><><><><><><><><><><><><>\n" +
|
ansiVersionOutline + "<><><><><><><><><><><><><><>-<><><><><><><><><><><><><><>\n" +
|
||||||
"\\" + ansiBlackOnWhite + " " + backend.AnsiReset + 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 + " The Placeholder Update " + backend.AnsiReset + ansiVersionOutline + "/\n" +
|
||||||
"\\" + ansiBlackOnWhite + " " + backend.AnsiReset + ansiVersionOutline + "/\n" +
|
"\\" + ansiBlackOnWhite + " " + backend.AnsiReset + ansiVersionOutline + "/\n" +
|
||||||
"\\" + ansiBlackOnWhite + " Copyright (c) 2024 Randall Winkhart " + backend.AnsiReset + ansiVersionOutline + "/\n" +
|
"\\" + ansiBlackOnWhite + " Copyright (c) 2024 Randall Winkhart " + backend.AnsiReset + ansiVersionOutline + "/\n" +
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ func writeEntryCLI(targetLocation string, unencryptedEntry []string, hidePasswor
|
|||||||
// write the entry to the target location
|
// write the entry to the target location
|
||||||
backend.WriteEntry(targetLocation, unencryptedEntry)
|
backend.WriteEntry(targetLocation, unencryptedEntry)
|
||||||
// preview the entry
|
// preview the entry
|
||||||
fmt.Println(ansiBold + "\nEntry Preview:" + backend.AnsiReset)
|
fmt.Println(AnsiBold + "\nEntry Preview:" + backend.AnsiReset)
|
||||||
EntryReader(unencryptedEntry, hidePassword, true)
|
EntryReader(unencryptedEntry, hidePassword, true)
|
||||||
} else {
|
} else {
|
||||||
fmt.Println(backend.AnsiError + "No data supplied for entry" + backend.AnsiReset)
|
fmt.Println(backend.AnsiError + "No data supplied for entry" + backend.AnsiReset)
|
||||||
|
|||||||
Reference in New Issue
Block a user