<commit_before>package main

import (
	"fmt"
	"os"
	"os/exec"
	"path/filepath"

	"github.com/sbinet/go-commander"
	"github.com/sbinet/go-flag"
)

func hwaf_make_cmd_waf_run() *commander.Command {
	cmd := &commander.Command{
		Run:       hwaf_run_cmd_waf_run,
		UsageLine: "run",
		Short:     "run a command with the correct (project) environment",
		Long: `
run a command with the correct (project) environment.

ex:
 $ hwaf run some-command --some-flag some-data
`,
		Flag:        *flag.NewFlagSet("hwaf-waf-run", flag.ExitOnError),
		CustomFlags: true,
	}
	return cmd
}

func hwaf_run_cmd_waf_run(cmd *commander.Command, args []string) {
	var err error
	//n := "hwaf-" + cmd.Name()

	top := hwaf_root()
	waf := filepath.Join(top, "bin", "waf")
	if !path_exists(waf) {
		err = fmt.Errorf(
			"no such file [%s]\nplease re-run 'hwaf self-init'\n",
			waf,
		)
		handle_err(err)
	}

	subargs := append([]string{"run"}, args...)
	sub := exec.Command(waf, subargs...)
	sub.Stdin = os.Stdin
	sub.Stdout = os.Stdout
	sub.Stderr = os.Stderr
	err = sub.Run()
	handle_err(err)
}

// EOF
<commit_msg>run: properly prepare args for subcommands (insert '--')<commit_after>package main

import (
	"fmt"
	"os"
	"os/exec"
	"path/filepath"

	"github.com/sbinet/go-commander"
	"github.com/sbinet/go-flag"
)

func hwaf_make_cmd_waf_run() *commander.Command {
	cmd := &commander.Command{
		Run:       hwaf_run_cmd_waf_run,
		UsageLine: "run",
		Short:     "run a command with the correct (project) environment",
		Long: `
run a command with the correct (project) environment.

ex:
 $ hwaf run some-command --some-flag some-data
`,
		Flag:        *flag.NewFlagSet("hwaf-waf-run", flag.ExitOnError),
		CustomFlags: true,
	}
	return cmd
}

func hwaf_run_cmd_waf_run(cmd *commander.Command, args []string) {
	var err error
	//n := "hwaf-" + cmd.Name()

	top := hwaf_root()
	waf := filepath.Join(top, "bin", "waf")
	if !path_exists(waf) {
		err = fmt.Errorf(
			"no such file [%s]\nplease re-run 'hwaf self-init'\n",
			waf,
		)
		handle_err(err)
	}

	subargs := append([]string{"run", "--"}, args...)
	sub := exec.Command(waf, subargs...)
	sub.Stdin = os.Stdin
	sub.Stdout = os.Stdout
	sub.Stderr = os.Stderr
	err = sub.Run()
	handle_err(err)
}

// EOF

{'fraction_non_alphanumeric': 0.16494845360824742, 'fraction_numerical': 0.0, 'mean_word_length': 3.4909456740442657, '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': '453151', 'n_tokens_mistral': 939, 'n_tokens_neox': 906, 'n_words': 197}