main function

Show/Hide Function Body
{
	rootCmd := root.NewRootCommand("rfw", "rfw [command]", "rfw command line interface", core.Version)

	rootCmd.AddCommand(commands.NewInitCommand())
	rootCmd.AddCommand(commands.NewDevCommand())
	rootCmd.AddCommand(commands.NewBuildCommand())

	if err := rootCmd.Execute(); err != nil {
		fmt.Fprintf(os.Stderr, "Error: %v\n", err)
		os.Exit(1)
	}
}

TestRootCommandSetup function

TestRootCommandSetup ensures main registers expected subcommands.

Parameters:

  • t *testing.T
Show/Hide Function Body
{
	cmd := root.NewRootCommand("rfw", "rfw [command]", "RFW command line interface", "0.0.0")
	cmd.AddCommand(commands.NewInitCommand())
	cmd.AddCommand(commands.NewDevCommand())
	cmd.AddCommand(commands.NewBuildCommand())
	for _, name := range []string{"init", "dev", "build"} {
		if _, ok := cmd.Commands[name]; !ok {
			t.Fatalf("expected subcommand %s registered", name)
		}
	}
}

fmt import

Import example:

import "fmt"

os import

Import example:

import "os"

github.com/mirkobrombin/go-cli-builder/v1/root import

Import example:

import "github.com/mirkobrombin/go-cli-builder/v1/root"

github.com/rfwlab/rfw/cmd/rfw/commands import

Import example:

import "github.com/rfwlab/rfw/cmd/rfw/commands"

github.com/rfwlab/rfw/v1/core import

Import example:

import "github.com/rfwlab/rfw/v1/core"

testing import

Import example:

import "testing"

github.com/mirkobrombin/go-cli-builder/v1/root import

Import example:

import "github.com/mirkobrombin/go-cli-builder/v1/root"

Imported as:

root

github.com/rfwlab/rfw/cmd/rfw/commands import

Import example:

import "github.com/rfwlab/rfw/cmd/rfw/commands"