<commit_before>package app_run

import (
	"flag"
	"github.com/GeertJohan/go.rice"
	"github.com/pkg/profile"
	"github.com/watermint/toolbox/catalogue"
	"github.com/watermint/toolbox/infra/control/app_control"
	"github.com/watermint/toolbox/infra/control/app_control_impl"
	"github.com/watermint/toolbox/infra/control/app_opt"
	"github.com/watermint/toolbox/infra/control/app_root"
	"github.com/watermint/toolbox/infra/control/app_run_impl"
	"github.com/watermint/toolbox/infra/network/app_diag"
	"github.com/watermint/toolbox/infra/network/app_network"
	"github.com/watermint/toolbox/infra/quality/qt_control_impl"
	"github.com/watermint/toolbox/infra/recpie/app_kitchen"
	"github.com/watermint/toolbox/infra/recpie/app_recipe_group"
	"github.com/watermint/toolbox/infra/recpie/app_vo_impl"
	"github.com/watermint/toolbox/infra/ui/app_msg"
	"github.com/watermint/toolbox/infra/ui/app_ui"
	"go.uber.org/zap"
	"os"
	"os/signal"
	"runtime"
	"strings"
	"syscall"
)

func Run(args []string, bx, web *rice.Box) (found bool) {
	// Initialize resources
	mc := app_run_impl.NewContainer(bx)
	ui := app_ui.NewConsole(mc, qt_control_impl.NewMessageMock(), false)
	cat := catalogue.Catalogue()

	// Select recipe or group
	cmd, grp, rcp, rem, err := cat.Select(args)

	switch {
	case err != nil:
		//if grp != nil {
		//	grp.PrintUsage(ui)
		//} else {
		//	cat.PrintUsage(ui)
		//}
		//os.Exit(app_control.FailureInvalidCommand)
		return false

	case rcp == nil:
		grp.PrintUsage(ui)
		os.Exit(app_control.Success)
	}

	// Initialize recipe value object
	cmdPath := make([]string, 0)
	cmdPath = append(cmdPath, grp.Path...)
	if cmd != "" {
		cmdPath = append(cmdPath, cmd)
	}<commit_msg>fix #186 : usage was not shown when invalid command<commit_after>package app_run

import (
	"flag"
	"github.com/GeertJohan/go.rice"
	"github.com/pkg/profile"
	"github.com/watermint/toolbox/catalogue"
	"github.com/watermint/toolbox/infra/control/app_control"
	"github.com/watermint/toolbox/infra/control/app_control_impl"
	"github.com/watermint/toolbox/infra/control/app_opt"
	"github.com/watermint/toolbox/infra/control/app_root"
	"github.com/watermint/toolbox/infra/control/app_run_impl"
	"github.com/watermint/toolbox/infra/network/app_diag"
	"github.com/watermint/toolbox/infra/network/app_network"
	"github.com/watermint/toolbox/infra/quality/qt_control_impl"
	"github.com/watermint/toolbox/infra/recpie/app_kitchen"
	"github.com/watermint/toolbox/infra/recpie/app_recipe_group"
	"github.com/watermint/toolbox/infra/recpie/app_vo_impl"
	"github.com/watermint/toolbox/infra/ui/app_msg"
	"github.com/watermint/toolbox/infra/ui/app_ui"
	"go.uber.org/zap"
	"os"
	"os/signal"
	"runtime"
	"strings"
	"syscall"
)

func Run(args []string, bx, web *rice.Box) (found bool) {
	// Initialize resources
	mc := app_run_impl.NewContainer(bx)
	ui := app_ui.NewConsole(mc, qt_control_impl.NewMessageMock(), false)
	cat := catalogue.Catalogue()

	// Select recipe or group
	cmd, grp, rcp, rem, err := cat.Select(args)

	switch {
	case err != nil:
		if grp != nil {
			grp.PrintUsage(ui)
		} else {
			cat.PrintUsage(ui)
		}
		os.Exit(app_control.FailureInvalidCommand)

	case rcp == nil:
		grp.PrintUsage(ui)
		os.Exit(app_control.Success)
	}

	// Initialize recipe value object
	cmdPath := make([]string, 0)
	cmdPath = append(cmdPath, grp.Path...)
	if cmd != "" {
		cmdPath = append(cmdPath, cmd)
	}
{'fraction_non_alphanumeric': 0.15055043141922048, 'fraction_numerical': 0.001487652484379649, 'mean_word_length': 4.547854785478548, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1760803', 'n_tokens_mistral': 1408, 'n_tokens_neox': 1341, 'n_words': 180}