Commit 55d4538f authored by Mickaël Desfrênes's avatar Mickaël Desfrênes
Browse files

add basex-gui command

parent e0befe94
Loading
Loading
Loading
Loading
+1 −1
Changes for LISEZMOI.md: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ Ce dossier contient l'implémentation de `climax`, la CLI utilisée pour gérer
`climax` est une CLI pour les développeurs/opérateurs de projets MaX. Elle permet de :

- créer et initialiser des projets MaX (`new`, `sync`, `demo`)
- lancer et arrêter la stack MaX/BaseX (`start`, `stop`, `basex`)
- lancer et arrêter la stack MaX/BaseX (`start`, `stop`, `basex`, `basex-gui`)
- inspecter la configuration (`info`, `projects`)
- gérer les bundles (`bundles-list`, `bundles-add`, `bundles-remove`)
- importer du contenu XML (`feed`)
+1 −1
Changes for README.md: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ This directory contains the implementation of `climax`, the CLI used to manage [
`climax` is a developer/operator CLI for MaX projects. It helps you:

- create and initialize MaX projects (`new`, `sync`, `demo`)
- run and stop the MaX/BaseX stack (`start`, `stop`, `basex`)
- run and stop the MaX/BaseX stack (`start`, `stop`, `basex`, `basex-gui`)
- inspect configuration (`info`, `projects`)
- manage bundles (`bundles-list`, `bundles-add`, `bundles-remove`)
- feed XML content (`feed`)
+16 −0
Changes for cli.go: 16 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ func newRootCmd() *cobra.Command {
	cmd.AddCommand(newFeedCmd())
	cmd.AddCommand(newSyncCmd())
	cmd.AddCommand(newBasexCmd())
	cmd.AddCommand(newBasexGUICmd())
	cmd.AddCommand(newTemplatesListCmd())
	cmd.AddCommand(newStaticListCmd())
	cmd.AddCommand(newProjectsCmd())
@@ -235,6 +236,21 @@ func newBasexCmd() *cobra.Command {
	return cmd
}

func newBasexGUICmd() *cobra.Command {
	directory := cwd()
	verbose := false
	cmd := &cobra.Command{
		Use:   "basex-gui",
		Short: T("cmd.basex_gui.short"),
		RunE: func(cmd *cobra.Command, args []string) error {
			return runBasexGUI(directory, verbose)
		},
	}
	cmd.Flags().StringVar(&directory, "directory", directory, T("flag.common.directory"))
	cmd.Flags().BoolVar(&verbose, "verbose", false, T("flag.basex.verbose"))
	return cmd
}

func newTemplatesListCmd() *cobra.Command {
	directory := cwd()
	cmd := &cobra.Command{
+3 −0
Changes for cli_commands_test.go: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ func TestRootRegistersAllCLICommands(t *testing.T) {
	got := availableCommandNames(root)
	want := []string{
		"basex",
		"basex-gui",
		"bundles-add",
		"bundles-list",
		"bundles-remove",
@@ -64,6 +65,7 @@ func TestCLICommandsExposeExpectedFlags(t *testing.T) {
		"feed":           {"directory", "verbose", "yes"},
		"sync":           {"directory"},
		"basex":          {"directory", "verbose"},
		"basex-gui":      {"directory", "verbose"},
		"templates-list": {"directory"},
		"static-list":    {"directory"},
		"projects":       {"json-out"},
@@ -127,6 +129,7 @@ func TestHelpRunsForAllCLICommands(t *testing.T) {
			{"feed", "dummy", "--help"},
			{"sync", "--help"},
			{"basex", "--help"},
			{"basex-gui", "--help"},
			{"templates-list", "--help"},
			{"static-list", "--help"},
			{"projects", "--help"},
+15 −0
Changes for commands.go: 15 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -386,6 +386,21 @@ func runBasex(directory string, verbose bool) error {
	return cmd.Run()
}

func runBasexGUI(directory string, verbose bool) error {
	abs, _, err := loadProject(directory)
	if err != nil {
		return err
	}
	cmd, err := newBaseXCommand(abs, "org.basex.BaseXGUI")
	if err != nil {
		return err
	}
	if verbose {
		fmt.Println(formatCommand(cmd))
	}
	return cmd.Run()
}

// Listing commands intentionally output plain relative paths, not tables; tests
// and users rely on piping these paths directly.
func scanDir(startPath, extension string) ([]string, error) {
Loading