help

package
v0.0.0-...-ad6479d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2024 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const Usage = `

# Boa Constructor

##	Invoking Boa Constructor from the command line

###	boa-constructor  [commands] [flags]

###	Commands Flags:

#### --gui             *--gui causes boa constructor to generate Gui friendly help and run schemes.*
-	Alias:       -g
-	Parameter count: none              Boolean
-	Parameter optional:   NA
-	Exclusive command:   No
-	Default command:     No
-	Required command:    No 
See more... [Long Descriptions](#long-descriptions-of-commands)
---
#### --mdhelp          *--mdhelp is a boolean command to cause help generation to generate markdown content.*
-	Alias:       -m
-	Parameter count: none              Boolean
-	Parameter optional:   NA
-	Exclusive command:   No
-	Default command:     No
-	Required command:    No 
See more... [Long Descriptions](#long-descriptions-of-commands)
---
###    file             *file passes a path to open a .json file to start the session.*
-   Alias:   No Alias
-	Parameter count: 1            File Path
-	Parameter optional:   NA
-	Exclusive command:   No
-	Default command:     No
-	Required command:    No 
See more... [Long Descriptions](#long-descriptions-of-commands)

---

### Using Boa-Constructor:
The boa-constructor
GUI app lets the developer lay out the cli of their app
by filling in text entries, checking boxes and selecting from drop
down  selectors.  The names of allowable commands and flags along
with the number, type and optional/required status of the parameters
to commands and flags can be defined.  Where possible validation
is done to catch command line input errors by users of the app being
designed. There are a number of data types that can be validated during 
the parsing process.
- File Path
- Integer
- Float
- Time
- Time Duration
- Date
- Phone Number
- Email Address
- Ip Address
- URL

Developers will have to validate strings and other types parsed as strings as that data could be almost anything.

During the design stages of your app your work can be saved and recalled later for editing. 
The JSON data generated by boa-constructor will be passed to the Boa
library function boa.FromJSON() as below:

` + "`" + "`" + "`" + ` go
    // this code is generated in the runcli.go file
    import "github.com/westarver/boa"

    func Runcli(w io.Writer) int {
        cli := boa.FromJSON(jsonBytes(), os.Args)
        if cli == nil {
            fmt.Fprintf(w, "%s\n", "unable to obtain cli object")
            return -1
        }
    // cli implementation ...
` + "`" + "`" + "`" + `

Call from your app and your app will receive a data structure (cli in the above example)containing the
command line args with parameters etc. Go code to start your app,
get and evaluate the commands received, and implement the help command
can be generated from the GUI. The current implementation creates three
source files, main.go, runcli.go and help.go.  These file names are only
defaults and can be changed at source generation time.

A couple of more things of note:<br>
Any command that can accept a variable number of, or optional parameters (one or more / zero or any number)
must have the parameter list end with the sentinel string -- (dash dash), unless nothing else follows. 
A parameter with spaces must be quoted.  John Doe would be seen as two strings, "John Doe" will be parsed correctly.
A few examples are in order:

` + "`" + "`" + "`" + ` bash
   # cmd takes variable number of parameters so use -- to end list
   $ my-app cmd 1st 2nd -- -f=1

   # no dashes required at the end of line
   $ my-app -f 1 cmd 1st 2nd  
   # also note the = sign is optional -f 1 == -f=1
` + "`" + "`" + "`" + `
 
### Long descriptions of commands
--gui: just a bunch of text to simulate a long description.

--mdhelp: long help for mdhelp.

file: long help for file.

[back to commands](#commands-flags)
`

Variables

This section is empty.

Functions

func ShowHelp

func ShowHelp() string

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL