Example #1
0
// Branch creates a new branch off of the current branch
// and switches the working branch to the new one.
func Branch(title string) {
	clean, err := isClean()
	if err != nil {
		fmt.Println(err)
		return
	}
	if !clean {
		status.Status()
		fmt.Println("\x1b[31;1mCommit changes before branching\x1b[0m")
		return
	}
	_, err = newBranch(title)
	if err != nil {
		fmt.Println(err)
		return
	}
}
Example #2
0
func main() {
	if len(os.Args) < 2 {
		displayHelp()
		return
	}

	//Check command
	//Add new commands to this list
	switch os.Args[1] {
	case "init":
		initialize.Initialize()
	case "commit":
		commit.Commit()
	case "status":
		status.Status()
	case "branch":
		if len(os.Args) >= 3 {
			branch.Branch(strings.Join(os.Args[2:], " "))
		} else {
			branch.Display()
		}
	//case "merge":
	case "log":
		log.Display()
	case "reset":
		reset.Reset()
	case "revert":
		if len(os.Args) != 3 {
			displayHelp()
			return
		}
		n, err := strconv.Atoi(os.Args[2])
		if err != nil {
			fmt.Println(err)
			os.Exit(2)
		}
		revert.Revert(n)
	case "delete":
		remove.Remove()
	//case "tutorial":
	case "help":
		displayHelp()
	default:
		displayHelp()
	}
}