diff --git a/cli/node.py b/cli/node.py index 51fbc420..01b4b27a 100644 --- a/cli/node.py +++ b/cli/node.py @@ -49,6 +49,7 @@ def convert(self, value, param, ctx): param, ctx) if not all([result.scheme, result.netloc]): self.fail(f'Expected valid url. Got {value}', param, ctx) + return value class IpType(click.ParamType): @@ -60,6 +61,11 @@ def convert(self, value, param, ctx): except ValueError: self.fail(f'expected valid ipv4/ipv6 address. Got {value}', param, ctx) + return value + + +URL_TYPE = UrlType() +IP_TYPE = IpType() @click.group() @@ -106,7 +112,7 @@ def node_about(format): @click.option( '--ip', prompt="Enter node public IP", - type=IpType(), + type=IP_TYPE, help='Public IP for RPC connections & consensus (required)' ) @click.option( @@ -126,7 +132,7 @@ def register_node(name, ip, port): @click.option('--install-deps', is_flag=True) @click.option( # todo: tmp option - after stable release branch '--mta-endpoint', - type=UrlType(), + type=URL_TYPE, # prompt="Enter Git branch to clone", help='MTA endpoint to connect', default=DEFAULT_MTA_ENDPOINT @@ -153,7 +159,7 @@ def register_node(name, ip, port): ) @click.option( # todo: tmp option - remove after mainnet deploy '--endpoint', - type=UrlType(), + type=URL_TYPE, # prompt="Enter Mainnet RPC port", help='RPC endpoint of the node in the network ' 'where SKALE manager is deployed', @@ -161,7 +167,7 @@ def register_node(name, ip, port): ) @click.option( # todo: tmp option - remove after mainnet deploy '--rpc-ip', - type=IpType(), + type=IP_TYPE, # prompt="Enter Mainnet RPC IP", help='IP of the node in the network where SKALE manager is deployed', default=DEFAULT_RPC_IP @@ -247,7 +253,7 @@ def purge_node(): prompt='Are you sure you want to update SKALE node software?') @click.option( # todo: tmp option - after stable release branch '--mta-endpoint', - type=UrlType(), + type=URL_TYPE, # prompt="Enter Git branch to clone", help='MTA endpoint to connect', default=DEFAULT_MTA_ENDPOINT @@ -269,7 +275,7 @@ def purge_node(): ) @click.option( # todo: tmp option - remove after mainnet deploy '--endpoint', - type=UrlType(), + type=URL_TYPE, # prompt="Enter Mainnet RPC port", help='RPC endpoint of the node in the network ' 'where SKALE manager is deployed', @@ -277,7 +283,7 @@ def purge_node(): ) @click.option( # todo: tmp option - remove after mainnet deploy '--rpc-ip', - type=IpType(), + type=IP_TYPE, # prompt="Enter Mainnet RPC IP", help='IP of the node in the network where SKALE manager is deployed', default=DEFAULT_RPC_IP diff --git a/main.py b/main.py index cdd6dcb2..73ab7fef 100644 --- a/main.py +++ b/main.py @@ -55,9 +55,9 @@ def cli(): @click.option('--short', is_flag=True) def version(short): if short: - print(__version__) + print(VERSION) else: - print(f'SKALE Node CLI version: {__version__}') + print(f'SKALE Node CLI version: {VERSION}') @cli.command('info', help="Show SKALE node CLI info") diff --git a/scripts/calculate_version.sh b/scripts/calculate_version.sh index c66b7abf..eb58ea15 100644 --- a/scripts/calculate_version.sh +++ b/scripts/calculate_version.sh @@ -1,5 +1,13 @@ #!/usr/bin/env bash VERSION=$(python setup.py --version) +USAGE_MSG='Usage: BRANCH=[BRANCH] calculate_version.sh' + +if [ -z "$BRANCH" ] +then + (>&2 echo 'You should provide branch') + echo $USAGE_MSG + exit 1 +fi if [ -z $VERSION ]; then @@ -12,12 +20,12 @@ if [[ $BRANCH == 'stable' ]]; then exit 1 fi -git fetch --tags +git fetch --tags > /dev/null for (( NUMBER=0; ; NUMBER++ )) do FULL_VERSION="$VERSION-$BRANCH.$NUMBER" - if ! [ $(git tag -l ?$FULL_VERSION) ]; then + if ! [ $(git tag -l | grep $FULL_VERSION) ]; then echo "$FULL_VERSION" | tr / - break fi