<commit_before>package commandargs

import (
	"errors"

	"gitlab.com/gitlab-org/gitlab-shell/internal/executable"
	"gitlab.com/gitlab-org/gitlab-shell/internal/sshenv"
)

type CommandType string

type CommandArgs interface {
	Parse() error
	GetArguments() []string
}

func Parse(e *executable.Executable, arguments []string, env sshenv.Env) (CommandArgs, error) {
	var args CommandArgs

	switch e.Name {
	case executable.GitlabShell:
		args = &Shell{Arguments: arguments, Env: env}
	case executable.AuthorizedKeysCheck:
		args = &AuthorizedKeys{Arguments: arguments}
	case executable.AuthorizedPrincipalsCheck:
		args = &AuthorizedPrincipals{Arguments: arguments}
	case executable.Healthcheck:
		return args, nil
	default:
		return nil, errors.New("unknown executable")
	}

	if err := args.Parse(); err != nil {
		return nil, err
	}

	return args, nil
}<commit_msg>refactor: improve unknown executable error message<commit_after>package commandargs

import (
	"errors"
	"fmt"

	"gitlab.com/gitlab-org/gitlab-shell/internal/executable"
	"gitlab.com/gitlab-org/gitlab-shell/internal/sshenv"
)

type CommandType string

type CommandArgs interface {
	Parse() error
	GetArguments() []string
}

func Parse(e *executable.Executable, arguments []string, env sshenv.Env) (CommandArgs, error) {
	var args CommandArgs

	switch e.Name {
	case executable.GitlabShell:
		args = &Shell{Arguments: arguments, Env: env}
	case executable.AuthorizedKeysCheck:
		args = &AuthorizedKeys{Arguments: arguments}
	case executable.AuthorizedPrincipalsCheck:
		args = &AuthorizedPrincipals{Arguments: arguments}
	case executable.Healthcheck:
		return args, nil
	default:
		return nil, errors.New(fmt.Sprintf("unknown executable: %s", e.Name))
	}

	if err := args.Parse(); err != nil {
		return nil, err
	}

	return args, nil
}
{'fraction_non_alphanumeric': 0.11117287381878821, 'fraction_numerical': 0.0, 'mean_word_length': 5.122448979591836, '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': '1128', 'n_tokens_mistral': 611, 'n_tokens_neox': 576, 'n_words': 144}