Skip to content

Commit

Permalink
correct wrong comma placements
Browse files Browse the repository at this point in the history
add new function cmdLineSyntax() to avoid repeatedly typing this mass of text
remove leftover comment line
  • Loading branch information
angelabriel committed Jul 23, 2024
1 parent 8ca7e9f commit e4420c6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 52 deletions.
18 changes: 11 additions & 7 deletions actions/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,8 @@ func switchOffColor() {
}
}

// PrintHelpAndExit prints the usage and exit
func PrintHelpAndExit(writer io.Writer, exitStatus int) {
if system.GetFlagVal("format") == "json" {
system.JInvalid(exitStatus)
}
fmt.Fprintln(writer, `saptune: Comprehensive system optimisation management for SAP solutions.
func cmdLineSyntax() string {
return `saptune: Comprehensive system optimisation management for SAP solutions.
Daemon control:
saptune [--format FORMAT] [--force-color] daemon ( start | stop | status [--non-compliance-check] ) ATTENTION: deprecated
saptune [--format FORMAT] [--force-color] service ( start | stop | restart | takeover | enable | disable | enablestart | disablestop | status [--non-compliance-check] )
Expand Down Expand Up @@ -325,6 +321,14 @@ Print this message:
Deprecation list:
all 'saptune daemon' actions
'saptune note simulate'
'saptune solution simulate'`)
'saptune solution simulate' `
}

// PrintHelpAndExit prints the usage and exit
func PrintHelpAndExit(writer io.Writer, exitStatus int) {
if system.GetFlagVal("format") == "json" {
system.JInvalid(exitStatus)
}
fmt.Fprintln(writer, cmdLineSyntax())
system.ErrorExit("", exitStatus)
}
40 changes: 1 addition & 39 deletions actions/actionsMatchtxt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ Remember: if you wish to automatically activate the note's and solution's tuning
`, "balanced", system.GetVirtStatus())

//`, system.GetTunedAdmProfile(), system.GetVirtStatus())

var saptuneStatMatchText = fmt.Sprintf(`
saptune.service: disabled/inactive
saptune package: 'undef'
Expand All @@ -86,40 +84,4 @@ Your system has not yet been tuned. Please visit `+"`"+`saptune note`+"`"+` and
`, system.GetTunedAdmProfile(), system.GetVirtStatus())

var PrintHelpAndExitMatchText = `saptune: Comprehensive system optimisation management for SAP solutions.
Daemon control:
saptune [--format FORMAT] [--force-color] daemon ( start | stop | status [--non-compliance-check] ) ATTENTION: deprecated
saptune [--format FORMAT] [--force-color] service ( start | stop | restart | takeover | enable | disable | enablestart | disablestop | status [--non-compliance-check] )
Tune system according to SAP and SUSE notes:
saptune [--format FORMAT] [--force-color] note ( list | revertall | enabled | applied )
saptune [--format FORMAT] [--force-color] note ( apply | simulate | customise | create | edit | revert | show | delete ) NOTEID
saptune [--format FORMAT] [--force-color] note verify [--colorscheme SCHEME] [--show-non-compliant] [NOTEID]
saptune [--format FORMAT] [--force-color] note rename NOTEID NEWNOTEID
Tune system for all notes applicable to your SAP solution:
saptune [--format FORMAT] [--force-color] solution ( list | verify | enabled | applied )
saptune [--format FORMAT] [--force-color] solution ( apply | simulate | customise | create | edit | revert | show | delete ) SOLUTIONNAME
saptune [--format FORMAT] [--force-color] solution change [--force] SOLUTIONNAME
saptune [--format FORMAT] [--force-color] solution verify [--colorscheme SCHEME] [--show-non-compliant] [SOLUTIONNAME]
saptune [--format FORMAT] [--force-color] solution rename SOLUTIONNAME NEWSOLUTIONNAME
Staging control:
saptune [--format FORMAT] [--force-color] staging ( status | enable | disable | is-enabled | list )
saptune [--format FORMAT] [--force-color] staging ( analysis | diff ) [ ( NOTEID | SOLUTIONNAME )... | all ]
saptune [--format FORMAT] [--force-color] staging release [--force|--dry-run] [ ( NOTEID | SOLUTIONNAME )... | all ]
Revert all parameters tuned by the SAP notes or solutions:
saptune [--format FORMAT] [--force-color] revert all
Remove the pending lock file from a former saptune call
saptune [--format FORMAT] [--force-color] lock remove
Call external script '/usr/sbin/saptune_check'
saptune [--format FORMAT] [--force-color] check
Print current saptune status:
saptune [--format FORMAT] [--force-color] status [--non-compliance-check]
Print current saptune version:
saptune [--format FORMAT] [--force-color] version
Print this message:
saptune [--format FORMAT] [--force-color] help
Deprecation list:
all 'saptune daemon' actions
'saptune note simulate'
'saptune solution simulate'
`
var PrintHelpAndExitMatchText = cmdLineSyntax()
12 changes: 6 additions & 6 deletions system/argsAndFlags.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ func CliArgs(i int) []string {
return []string{}
}

// IsFlagSet returns true, if the flag is available on the command line
// or false, if not
// IsFlagSet returns true if the flag is available on the command line
// or false if not
func IsFlagSet(flag string) bool {
if saptFlags[flag] == "false" || saptFlags[flag] == "" {
return false
Expand Down Expand Up @@ -67,7 +67,7 @@ func ParseCliArgs() ([]string, map[string]string) {
}
if strings.HasPrefix(arg, "--") || strings.HasPrefix(arg, "-") {
// argument is a flag
// skip next command line parameter, if it is the value
// skip next command line parameter if it is the value
// belonging to a flag
skip = handleFlags(arg, i, stFlags)
continue
Expand Down Expand Up @@ -142,7 +142,7 @@ func setUnsupportedFlag(val string, flags map[string]string) {
}
}

// ChkCliSyntax checks, if command line parameter are in the right order
// ChkCliSyntax checks if command line parameter are in the right order
// only checking the right position of the 'options' aka 'flags'
// saptune globOpt realm realmOpt cmd cmdOpt param
func ChkCliSyntax() bool {
Expand Down Expand Up @@ -260,7 +260,7 @@ func chkGlobalOpts(cmdLinePos map[string]int) bool {
return ret
}

// chkGlobalFlag checks, if the global flags are on the right position in the
// chkGlobalFlag checks if the global flags are on the right position in the
// command line
func chkGlobalFlag(flag string, cliArg string, result bool, globOpt bool) (bool, bool) {
fval := "-" + flag
Expand Down Expand Up @@ -349,7 +349,7 @@ func chkCmdOpts(cmdLinePos map[string]int) bool {
return ret
}

// checkFlag checks, if the command flags are on the right position in the
// checkFlag checks if the command flags are on the right position in the
// command line
func checkFlag(cmdLinePos map[string]int, flagValue string) bool {
stArgs := os.Args
Expand Down

0 comments on commit e4420c6

Please sign in to comment.