<commit_before>package commands

import "fmt"

type CompletionCommand struct {
	Bash BashCompletionCommand `command:"bash"`
	// TODO: support more shells
}

type BashCompletionCommand struct {}

// credits:
// https://godoc.org/github.com/jessevdk/go-flags#hdr-Completion
// https://github.com/concourse/concourse/issues/1309#issuecomment-452893900
const bashCompletionSnippet = `_fly_compl() {
	args=("${COMP_WORDS[@]:1:$COMP_CWORD}")
	local IFS=$'\n'
	COMPREPLY=($(GO_FLAGS_COMPLETION=1 ${COMP_WORDS[0]} "${args[@]}"))
	return 0
}
complete -F _fly_compl fly
`

func (*BashCompletionCommand) Execute([]string) error {
	_, err := fmt.Print(bashCompletionSnippet)
	return err
}<commit_msg>make shell for completion a parameter instead of a subcommand<commit_after>package commands

import "fmt"

type CompletionCommand struct {
	Shell string `long:"shell" required:"true" choice:"bash"` // add more choices later
}

// credits:
// https://godoc.org/github.com/jessevdk/go-flags#hdr-Completion
// https://github.com/concourse/concourse/issues/1309#issuecomment-452893900
const bashCompletionSnippet = `_fly_compl() {
	args=("${COMP_WORDS[@]:1:$COMP_CWORD}")
	local IFS=$'\n'
	COMPREPLY=($(GO_FLAGS_COMPLETION=1 ${COMP_WORDS[0]} "${args[@]}"))
	return 0
}
complete -F _fly_compl fly
`

func (*CompletionCommand) Execute([]string) error {
	_, err := fmt.Print(bashCompletionSnippet)
	return err
}
{'fraction_non_alphanumeric': 0.15589080459770116, 'fraction_numerical': 0.02442528735632184, 'mean_word_length': 5.896039603960396, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '2942998', 'n_tokens_mistral': 504, 'n_tokens_neox': 479, 'n_words': 94}