<commit_before>package facade

import (
	"errors"
	"flag"
	"fmt"
	"os"
	"path"
	"strings"

	"github.com/spiegel-im-spiegel/gocli"
	"github.com/spiegel-im-spiegel/gpgpdump/internal/parse"
)

// Exit Status
const (
	ExitSuccess = iota
	ExitFailure
)

// Errors
var (
	ErrFacadeTest = errors.New("facade test")
)

// Facade of facade context
type Facade struct {
	// UI is Command line user interface
	*gocli.UI
	// Name of application
	Name string
	// Version of application
	Version string
}

// NewFacade returns a new Facade instance
func NewFacade(appName, version string, ui *gocli.UI) *Facade {
	return &Facade{UI: ui, Name: appName, Version: version}
}

// Run Application
func (f *Facade) Run(args []string) (int, error) {
	cmd := parse.Command(f.UI)

	flags := flag.NewFlagSet(f.Name, flag.ContinueOnError)
	flags.BoolVar(&cmd.Hflag, "h", false, "displays this help")
	flags.BoolVar(&cmd.Vflag, "v", false, "displays version")
	flags.BoolVar(&cmd.Aflag, "a", false, "accepts ASCII input only")
	flags.BoolVar(&cmd.Gflag, "g", false, "selects alternate dump format")
	flags.BoolVar(&cmd.Iflag, "i", false, "dumps integer packets")
	flags.BoolVar(&cmd.Lflag, "l", false, "dumps literal packets")
	flags.BoolVar(&cmd.Mflag, "m", false, "dumps marker packets")
	flags.BoolVar(&cmd.Pflag, "p", false, "dumps private packets")
	flags.BoolVar(&cmd.Uflag, "u", false, "displays UTC time")
	ftest := flags.Bool("ftest", false, "facade test")
	flags.Usage = func() {
		f.showUsage()
	}
	// Parse commandline flag
	if err := flags.Parse(args); err != nil {
		return ExitFailure, nil
	}
	if cmd.Hflag {
		f.showUsage()
		return ExitSuccess, nil
	}
	if cmd.Vflag {
		f.showVersion()
		return ExitSuccess, nil
	}

	switch flags.NArg() {
	case 0:
		cmd.InputFile = ""
	case 1:
		cmd.InputFile = flags.Arg(0)
	default:
		return ExitFailure, os.ErrInvalid
	}

	if *ftest { // for facade test
		return ExitSuccess, ErrFacadeTest
	}
	if err := cmd.Run(); err != nil {
		return ExitFailure, err
	}
	return ExitSuccess, nil
}

func (f *Facade) showUsage() {
	usageText := `
USAGE:
   %s [options] [OpenPGP file]

OPTIONS:
   -h -- displays this help
   -v -- displays version
   -a -- accepts ASCII input only
   -g -- selects alternate dump format
   -i -- dumps integer packets
   -l -- dumps literal packets
   -m -- dumps marker packets
   -p -- dumps private packets
   -u -- displays UTC time
`
	f.OutputErrln(fmt.Sprintf(strings.Trim(usageText, " \t\n\r"), f.Name))
}
<commit_msg>remove -g option.<commit_after>package facade

import (
	"errors"
	"flag"
	"fmt"
	"os"
	"path"
	"strings"

	"github.com/spiegel-im-spiegel/gocli"
	"github.com/spiegel-im-spiegel/gpgpdump/internal/parse"
)

// Exit Status
const (
	ExitSuccess = iota
	ExitFailure
)

// Errors
var (
	ErrFacadeTest = errors.New("facade test")
)

// Facade of facade context
type Facade struct {
	// UI is Command line user interface
	*gocli.UI
	// Name of application
	Name string
	// Version of application
	Version string
}

// NewFacade returns a new Facade instance
func NewFacade(appName, version string, ui *gocli.UI) *Facade {
	return &Facade{UI: ui, Name: appName, Version: version}
}

// Run Application
func (f *Facade) Run(args []string) (int, error) {
	cmd := parse.Command(f.UI)

	flags := flag.NewFlagSet(f.Name, flag.ContinueOnError)
	flags.BoolVar(&cmd.Hflag, "h", false, "displays this help")
	flags.BoolVar(&cmd.Vflag, "v", false, "displays version")
	flags.BoolVar(&cmd.Aflag, "a", false, "accepts ASCII input only")
	//flags.BoolVar(&cmd.Gflag, "g", false, "selects alternate dump format") // do not use g option
	flags.BoolVar(&cmd.Iflag, "i", false, "dumps multi-precision integer")
	flags.BoolVar(&cmd.Lflag, "l", false, "dumps literal packets (tag 11)")
	flags.BoolVar(&cmd.Mflag, "m", false, "dumps marker packets (tag 10)")
	flags.BoolVar(&cmd.Pflag, "p", false, "dumps private packets (tag 60-63)")
	flags.BoolVar(&cmd.Uflag, "u", false, "displays UTC time")
	ftest := flags.Bool("ftest", false, "facade test")
	flags.Usage = func() {
		f.showUsage()
	}
	// Parse commandline flag
	if err := flags.Parse(args); err != nil {
		return ExitFailure, nil
	}
	if cmd.Hflag {
		f.showUsage()
		return ExitSuccess, nil
	}
	if cmd.Vflag {
		f.showVersion()
		return ExitSuccess, nil
	}

	switch flags.NArg() {
	case 0:
		cmd.InputFile = ""
	case 1:
		cmd.InputFile = flags.Arg(0)
	default:
		return ExitFailure, os.ErrInvalid
	}

	if *ftest { // for facade test
		return ExitSuccess, ErrFacadeTest
	}
	if err := cmd.Run(); err != nil {
		return ExitFailure, err
	}
	return ExitSuccess, nil
}

func (f *Facade) showUsage() {
	usageText := `
USAGE:
   %s [options] [OpenPGP file]

OPTIONS:
   -h -- displays this help
   -v -- displays version
   -a -- accepts ASCII input only
   -i -- dumps integer packets
   -l -- dumps literal packets
   -m -- dumps marker packets
   -p -- dumps private packets
   -u -- displays UTC time
`
	f.OutputErrln(fmt.Sprintf(strings.Trim(usageText, " \t\n\r"), f.Name))
}

{'fraction_non_alphanumeric': 0.14736630478488139, 'fraction_numerical': 0.0028146361077603537, 'mean_word_length': 3.6107506950880444, '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': '1305423', 'n_tokens_mistral': 1905, 'n_tokens_neox': 1819, 'n_words': 506}