Exemplo n.º 1
0
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

package main

import (
	"fmt"
	flag "maunium.net/go/mauflag"
)

var bf = flag.Make().LongKey("bff").ShortKey("b").Usage("Change the variable 'bf'").Bool()
var xb = flag.Make().ShortKey("x").Usage("Set the boolean X").UsageCategory("XYZ").Bool()
var yb = flag.Make().ShortKey("y").Usage("Set the boolean Y").UsageCategory("XYZ").Bool()
var zb = flag.Make().ShortKey("z").Usage("Set the boolean Z").UsageCategory("XYZ").Bool()
var str = flag.Make().LongKey("this-is-a-string").ShortKey("s").ShortKey("i").Usage("Set a string value").String()
var array = flag.Make().LongKey("array").ShortKey("a").LongKey("arr").Usage("Add values to an array").StringArray()
var def = flag.Make().LongKey("asd").Default("lorem").Usage("Change a variable").String()

func main() {
	flag.MakeHelpFlag()
	flag.SetHelpTitles("flagtest - Test the mauflag package", "mauflag [-b] [-x] [-y] [-z] [-s STRING] [-a ARRAY VALUE] [--asd STRING]")
	fmt.Println(flag.Parse())

	if flag.CheckHelpFlag() {
		return
	}
Exemplo n.º 2
0
package main

import (
	"fmt"
	flag "maunium.net/go/mauflag"
	"os"
	"strings"
)

var wantHelp = flag.Make().LongKey("help").ShortKey("h").Bool()
var function = flag.Make().LongKey("function").ShortKey("f").Bool()
var oneliner = flag.Make().LongKey("single-line").ShortKey("s").Bool()
var withArgs = flag.Make().LongKey("with-args").ShortKey("a").Bool()
var condition = flag.Make().LongKey("if").ShortKey("i").String()
var elseCmd = flag.Make().LongKey("else").ShortKey("e").String()
var elseCmdIsLiteral = flag.Make().LongKey("with-args").ShortKey("l").Bool()

var help = `Generates bash functions or alias commands using given values. Intended as an advanced aliasing system.

Usage:
  maulias [-afls] [-e elseCommand] [-i condition] <ALIAS> <COMMAND...>

Help options:
  -h, --help               Show this help page

Application options:
  -f, --function           Generate a function rather than an alias command.
  -s, --single-line        Generate a single-line function. Doesn't affect anything without --function
  -a, --with-args          Generate a function that also checks arguments. When used, --function is ignored
  -i, --if=CONDITION       If set, this will be used as the condition inside an if. Only works with --function. Doesn't work with --with-args
  -e, --else=CMD           The command to use in the else case (used with --with-args and --if)
Exemplo n.º 3
0
import (
	"bufio"
	"fmt"
	"os"
	"os/signal"
	"strings"
	"syscall"

	msg "github.com/sorcix/irc"
	"github.com/sorcix/irc/ctcp"
	irc "maunium.net/go/libmauirc"
	flag "maunium.net/go/mauflag"
)

var ip = flag.Make().ShortKey("a").LongKey("address").Usage("The address to connect to.").String()
var port = flag.Make().ShortKey("p").LongKey("port").Usage("The port to connect to.").Uint16()
var tls = flag.Make().ShortKey("s").LongKey("ssl").LongKey("tls").Usage("Whether or not to enable TLS.").Bool()
var wantHelp, _ = flag.MakeHelpFlag()

func main() {
	err := flag.Parse()
	flag.SetHelpTitles("lmitest - A simple program to test libmauirc.", "lmitest [-h] [-s] [-a IP ADDRESS] [-p PORT]")
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		flag.PrintHelp()
		os.Exit(1)
	} else if *wantHelp {
		flag.PrintHelp()
		os.Exit(0)
	}