Skip to content

Commit

Permalink
print version and bump to 0.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
taquangtrung committed Apr 2, 2023
1 parent daf08d8 commit 23e19b9
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "solc_detect"
version = "0.0.5"
version = "0.0.6"
authors = [{name="Ta Quang Trung"},]
description = "A tool to detect Solidity compiler version required by smart contracts"
dynamic = ["dependencies"]
Expand Down
7 changes: 4 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
lark==1.1.5
semantic-version==2.10.0
node-semver==0.9.0
lark>=1.1.5
semantic-version>=2.10
node-semver>=0.9
toml>=0.10
40 changes: 33 additions & 7 deletions solc_detect/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

import argparse

import toml

import solc_detect

from . import lib


Expand All @@ -18,9 +22,19 @@ def configure_cli_arguments():
add_help=False,
)

# Help
# Print version
arg_parser.add_argument(
"--verbal",
"-V",
"--version",
action="store_true",
default=False,
help="",
)

# Print verbose
arg_parser.add_argument(
"-v",
"--verbose",
action="store_true",
default=False,
help="",
Expand All @@ -36,25 +50,37 @@ def configure_cli_arguments():
)

# Input
arg_parser.add_argument("input_file", help="Input smart contracts")
arg_parser.add_argument(
"input_file", nargs="?", help="Input smart contracts"
)

# Parse CLI arguments
args = arg_parser.parse_args()

return args
return (args, arg_parser)


def main():
"""Main function"""
args = configure_cli_arguments()
(args, arg_parser) = configure_cli_arguments()

if args.version:
app_version = toml.load("pyproject.toml")["project"]["version"]
print(f"solc-detect v{app_version}")
arg_parser.exit()

input_file = args.input_file
if input_file is None:
print("Error: input Solidity file is not provided!\n")
arg_parser.print_usage()
arg_parser.exit()

pragma_version = lib.find_pragma_solc_version(input_file)
if args.verbal:
if args.verbose:
print("Detected pragmas:", pragma_version)

best_version = lib.find_best_solc_version_for_pragma(pragma_version)
if args.verbal:
if args.verbose:
print("Best version:", best_version)
else:
print(best_version)
Expand Down

0 comments on commit 23e19b9

Please sign in to comment.