Skip to content

Commit

Permalink
Add option --barcode/-B for printing unique barcode for test
Browse files Browse the repository at this point in the history
  • Loading branch information
andyone committed Oct 1, 2023
1 parent a81497f commit 484cf33
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ Options
--list-packages, -L List required packages
--list-packages-flat, -L1 List required packages in one line (useful for scripts)
--variables, -V List recipe variables
--barcode, -B Show unique barcode for test (based on recipe and required packages)
--time, -T Print execution time for every action
--format, -f format Output format (tap13|tap14|json|xml)
--dir, -d dir Path to working directory
--path, -p path Path to directory with binaries
Expand Down
14 changes: 10 additions & 4 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const (
OPT_LIST_PACKAGES = "L:list-packages"
OPT_LIST_PACKAGES_FLAT = "L1:list-packages-flat"
OPT_VARIABLES = "V:variables"
OPT_BARCODE = "B:barcode"
OPT_TIME = "T:time"
OPT_FORMAT = "f:format"
OPT_DIR = "d:dir"
Expand All @@ -76,6 +77,7 @@ var optMap = options.Map{
OPT_LIST_PACKAGES: {Type: options.BOOL},
OPT_LIST_PACKAGES_FLAT: {Type: options.BOOL},
OPT_VARIABLES: {Type: options.BOOL},
OPT_BARCODE: {Type: options.BOOL},
OPT_TIME: {Type: options.BOOL},
OPT_FORMAT: {},
OPT_DIR: {},
Expand Down Expand Up @@ -257,14 +259,17 @@ func process(file string) {
r.Dir, _ = filepath.Abs(filepath.Dir(file))
}

if options.GetB(OPT_LIST_PACKAGES) || options.GetB(OPT_LIST_PACKAGES_FLAT) {
switch {
case options.GetB(OPT_LIST_PACKAGES),
options.GetB(OPT_LIST_PACKAGES_FLAT):
listPackages(r.Packages)
os.Exit(0)
}

if options.GetB(OPT_VARIABLES) {
case options.GetB(OPT_VARIABLES):
listVariables(r)
os.Exit(0)
case options.GetB(OPT_BARCODE):
printBarcode(r)

Check failure on line 271 in cli/cli.go

View workflow job for this annotation

GitHub Actions / Go (1.21.x)

undefined: printBarcode
os.Exit(0)
}

if options.Has(OPT_ERROR_DIR) {
Expand Down Expand Up @@ -454,6 +459,7 @@ func genUsage() *usage.Info {
info.AddOption(OPT_LIST_PACKAGES, "List required packages")
info.AddOption(OPT_LIST_PACKAGES_FLAT, "List required packages in one line {s-}(useful for scripts){!}")
info.AddOption(OPT_VARIABLES, "List recipe variables")
info.AddOption(OPT_BARCODE, "Show unique barcode for test {s-}(based on recipe and required packages){!}")
info.AddOption(OPT_TIME, "Print execution time for every action")
info.AddOption(OPT_FORMAT, "Output format {s-}(tap13|tap14|json|xml){!}", "format")
info.AddOption(OPT_DIR, "Path to working directory", "dir")
Expand Down
2 changes: 1 addition & 1 deletion cli/executor/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func checkRPMPackages(pkgs []string) []error {
var errs []error

for _, pkgInfo := range strings.Split(string(output), "\n") {
if strings.Contains(pkgInfo, "is not installed") {
if strings.Contains(pkgInfo, " ") {
pkgName := strutil.ReadField(pkgInfo, 1, true)
errs = append(errs, fmt.Errorf("Package %s is not installed", pkgName))
}
Expand Down

0 comments on commit 484cf33

Please sign in to comment.