Exemple #1
0
func main() {
	var newline, tab, elseFormat string

	if *oneliner {
		newline = " "
		tab = ""
	} else {
		newline = "\n"
		tab = "	"
	}
	if *elseCmdIsLiteral {
		elseFormat = fmt.Sprint(tab, tab, "%[1]s", newline)
	} else {
		elseFormat = fmt.Sprint(tab, tab, "%[1]s \"$@\";", newline)
	}

	if strings.Contains(flag.Arg(0), " ") && !*withArgs {
		fmt.Println("Warning: Arguments not included, as --with-args wasn't used.")
		flag.Args()[0] = strings.Split(flag.Arg(0), " ")[0]
	} else if flag.NArg() < 2 {
		fmt.Println("Usage: maulias [-afhls] [-e elseCommand] [-i condition] <ALIAS> <COMMANDS...>")
		return
	}

	if *withArgs {
		aliasWithArgs(newline, tab, elseFormat)
	} else if *function {
		aliasFunction(newline, tab, elseFormat)
	} else {
		aliasSimple()
	}
}
Exemple #2
0
func aliasSimple() {
	fmt.Print("alias '", flag.Arg(0), "'='") // Alias beginning
	for i, arg := range flag.Args()[1:] {
		fmt.Print(replace(arg, '¤', '$')) // Commands
		if i+2 < flag.NArg() {
			fmt.Print(" && ")
		}
	}
	fmt.Print("'\n")
}