Skip to content

Commit

Permalink
compiled postmanCli using go compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
fchastanet committed Sep 7, 2024
1 parent 2bd43f7 commit cd133d9
Show file tree
Hide file tree
Showing 9 changed files with 1,876 additions and 1,545 deletions.
3,002 changes: 1,651 additions & 1,351 deletions bin/postmanCli

Large diffs are not rendered by default.

82 changes: 0 additions & 82 deletions src/_binaries/Postman/command.postmanCli.tpl

This file was deleted.

30 changes: 0 additions & 30 deletions src/_binaries/Postman/postmanCli.sh

This file was deleted.

66 changes: 66 additions & 0 deletions src/_binaries/Postman/postmanCli/postmanCli-binary.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
extends:
- "${BASH_TOOLS_ROOT_DIR}/src/_binaries/commandDefinitions/optionsVersion.yaml"
- "${FRAMEWORK_ROOT_DIR}/src/_binaries/commandDefinitions/defaultCommand.yaml"
- "${FRAMEWORK_ROOT_DIR}/src/_binaries/commandDefinitions/frameworkConfig.yaml"

vars:
SRC_FILE_PATH: src/_binaries/Postman/postmanCli/postmanCli-binary.yaml

compilerConfig:
targetFile: "${BASH_TOOLS_ROOT_DIR}/bin/postmanCli"
relativeRootDirBasedOnTargetDir: ..
srcDirs:
- ${BASH_TOOLS_ROOT_DIR}/src
binData:
commands:
default:
functionName: postmanCliCommand
version: "3.0"
copyrightBeginYear: 2020
commandName: postmanCli
beforeParseCallbacks:
- beforeParseCallback
unknownOptionCallbacks:
- unknownOption
unknownArgumentCallbacks:
- unknownOption
callbacks:
- postmanCliCommandCallback
definitionFiles:
20: ${BASH_TOOLS_ROOT_DIR}/src/_binaries/Postman/postmanCli/postmanCli-options.sh
mainFile: ${BASH_TOOLS_ROOT_DIR}/src/_binaries/Postman/postmanCli/postmanCli-main.sh
help: Push/Pull postman collections of all the configured repositories.
longDescription: longDescriptionFunction
args:
- type: String
min: 0
max: 1
help: argCommandHelpFunction
authorizedValues:
- value: pull
help: Pull
- value: push
help: Push
name: command
variableName: argCommand

- type: String
min: 0
max: -1
help: commandArgsHelpFunction
name: ref
variableName: commandArgs

optionGroups:
groupPushPull:
title: "PUSH/PULL OPTIONS:"

options:
- variableName: optionPostmanModelConfig
type: String
group: groupPushPull
help: optionPostmanModelConfigHelpFunction
helpValueName: configFile
alts:
- --postman-model
- -m
15 changes: 15 additions & 0 deletions src/_binaries/Postman/postmanCli/postmanCli-main.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

# shellcheck disable=SC2154
case "${argCommand}" in
pull)
Postman::Commands::pullCommand "${optionPostmanModelConfig}" "${commandArgs[@]}"
;;
push)
Postman::Commands::pushCommand "${optionPostmanModelConfig}" "${commandArgs[@]}"
;;
*)
Log::displayError "Invalid command ${argCommand}"
exit 1
;;
esac
59 changes: 59 additions & 0 deletions src/_binaries/Postman/postmanCli/postmanCli-options.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env bash

longDescriptionFunction() {
echo -e " ${__HELP_TITLE}EXIT CODES:${__HELP_NORMAL}"
echo -e " ${__HELP_OPTION_COLOR}1${__HELP_NORMAL}: if commit does not exists"
echo -e " ${__HELP_OPTION_COLOR}2${__HELP_NORMAL}: if ref is not convertible to commit oid"
echo -e " ${__HELP_OPTION_COLOR}3${__HELP_NORMAL}: if commit is not included in given branch"
}

optionHelpCallback() {
postmanCliCommandHelp
exit 0
}

optionPostmanModelConfigHelpFunction() {
echo " postmanCli model file to use"
echo " Default value: <currentDir>/postmanCli.collections.json"
}

argCommandHelpFunction() {
echo -e " ${__HELP_OPTION_COLOR}pull${__HELP_NORMAL}"
echo -e " Pull collections from Postman back to repositories."
echo -e " ${__HELP_OPTION_COLOR}push${__HELP_NORMAL}"
echo -e ' Push repositories collections to Postman.'
}

commandArgsHelpFunction() {
echo -e " List of postman collection's references to pull or push"
echo -e " or no argument to pull or push all the collections"
}

# shellcheck disable=SC2317 # if function is overridden
unknownOption() {
commandArgs+=("$1")
}

postmanCliCommandCallback() {
if [[ -z "${optionPostmanModelConfig}" ]]; then
optionPostmanModelConfig="${CURRENT_DIR}/postmanCli.collections.json"
fi
if [[ ! -f "${optionPostmanModelConfig}" ]]; then
Log::displayError "Please provide a valid postman config file, using --postman-model option."
exit 1
fi
if [[ "${displayConfig}" = "1" ]]; then
# shellcheck disable=SC2154
Postman::Model::validate "${optionPostmanModelConfig}" "config"
original_displayConfig
UI::drawLine "-"
printf '%-40s = %s\n' "POSTMAN_API_KEY" "${POSTMAN_API_KEY:0:15}...(truncated)"
exit 0
fi
}

eval "original_$(declare -f displayConfig | grep -v 'exit 0')"
declare displayConfig=0
displayConfig() {
displayConfig=1
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

# shellcheck source=src/batsHeaders.sh
source "$(cd "${BATS_TEST_DIRNAME}/../.." && pwd)/batsHeaders.sh"
source "$(cd "${BATS_TEST_DIRNAME}/../../.." && pwd)/batsHeaders.sh"

setup() {
export TMPDIR="${BATS_TEST_TMPDIR}"
Expand All @@ -21,18 +21,17 @@ function PostmanCli::display_help { #@test

function PostmanCli::config { #@test
run "${binDir}/postmanCli" --config -m "${rootDir}/conf/postmanCli/openApis.json"

#assert_output ""
assert_line --index 0 "Config"
assert_line --index 1 "--------------------------------------------------------------------------------"
assert_line --index 2 "BASH_FRAMEWORK_ARGV = ([0]=\"--config\" [1]=\"-m\" [2]=\"${rootDir}/conf/postmanCli/openApis.json\")"
assert_line --index 3 "BASH_FRAMEWORK_ARGV_FILTERED = ()"
assert_line --index 4 'BASH_FRAMEWORK_DISPLAY_LEVEL = "3"'
assert_line --index 5 "BASH_FRAMEWORK_ENV_FILES = ([0]=\"${HOME}/.bash-tools/.env\")"
assert_line --index 6 "BASH_FRAMEWORK_LOG_FILE = \"${TMPDIR}/logFile\""
assert_line --index 7 'BASH_FRAMEWORK_LOG_FILE_MAX_ROTATION = "5"'
assert_line --index 8 'BASH_FRAMEWORK_LOG_LEVEL = "0"'
assert_line --index 9 'BASH_FRAMEWORK_THEME = "default"'
assert_line --index 10 "--------------------------------------------------------------------------------"
assert_line --index 11 'POSTMAN_API_KEY = ...(truncated)'
assert_lines_count 12
assert_line --index 5 "BASH_FRAMEWORK_LOG_FILE = \"${TMPDIR}/logFile\""
assert_line --index 6 'BASH_FRAMEWORK_LOG_FILE_MAX_ROTATION = "5"'
assert_line --index 7 'BASH_FRAMEWORK_LOG_LEVEL = "0"'
assert_line --index 8 'BASH_FRAMEWORK_THEME = "default"'
assert_line --index 9 "--------------------------------------------------------------------------------"
assert_line --index 10 'POSTMAN_API_KEY = ...(truncated)'
assert_lines_count 11
}
76 changes: 76 additions & 0 deletions src/_binaries/Postman/postmanCli/testsData/postmanCli.help.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
SYNOPSIS:
Push/Pull postman collections of all the configured repositories.

USAGE: postmanCli [OPTIONS] [ARGUMENTS]
USAGE: postmanCli [--help|-h] [--config]
[--bash-framework-config <bash-framework-config>] [--verbose|-v] [-vv] [-vvv]
[--env-file <env-file>] [--log-level <log-level>] [--log-file <log-file>]
[--display-level <display-level>] [--no-color] [--theme <theme>] [--version]
[--quiet|-q] [--postman-model|-m <configFile>]

ARGUMENTS:
[command {single}]
pull
Pull collections from Postman back to repositories.
push
Push repositories collections to Postman.
[ref {list} (optional)]
List of postman collection's references to pull or push
or no argument to pull or push all the collections

GLOBAL OPTIONS:
--help, -h {single}
Displays this command help
--config {single}
Displays configuration
--bash-framework-config <bash-framework-config> {single}
Use alternate bash framework configuration.
--verbose, -v {single}
Info level verbose mode (alias of --display-level INFO)
-vv {single}
Debug level verbose mode (alias of --display-level DEBUG)
-vvv {single}
Trace level verbose mode (alias of --display-level TRACE)
--env-file <env-file> {list} (optional)
Load the specified env file (deprecated, please use --bash-framework-con
fig option instead)
--log-level <log-level> {single}
Set log level
Possible values: OFF, ERR, ERROR, WARN, WARNING, INFO, DEBUG, TRACE
--log-file <log-file> {single}
Set log file
--display-level <display-level> {single}
Set display level
Possible values: OFF, ERR, ERROR, WARN, WARNING, INFO, DEBUG, TRACE
--no-color {single}
Produce monochrome output. alias of --theme noColor.
--theme <theme> {single}
Choose color theme - default-force means colors will be produced even if
command is piped.
Possible values: default, default-force, noColor
Default value: default
--version {single}
Print version information and quit.
--quiet, -q {single}
Quiet mode, doesn't display any output.

PUSH/PULL OPTIONS:
--postman-model, -m <configFile> {single}
postmanCli model file to use
Default value: <currentDir>/postmanCli.collections.json


DESCRIPTION:
EXIT CODES:
1: if commit does not exists
2: if ref is not convertible to commit oid
3: if commit is not included in given branch

VERSION: 3.0

AUTHOR: [François Chastanet](https://github.com/fchastanet)

SOURCE FILE: https://github.com/fchastanet/bash-tools-framework/tree/master/src/_binaries/Postman/postmanCli/postmanCli-binary.yaml

LICENSE: MIT License
Copyright (c) 2020-now François Chastanet
Loading

0 comments on commit cd133d9

Please sign in to comment.