Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): file is optional #65

Merged
merged 4 commits into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Examples of these are:
### Rule names
Obtain the names of the currently implemented rules with:
```bash
amarna --show-rules .
amarna --show-rules
```

### Rule allowlist
Expand Down
9 changes: 9 additions & 0 deletions amarna/command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def main() -> int:
metavar="-f",
type=str,
help="the name of the .cairo file or directory with .cairo files to analyze",
nargs="?",
)

parser.add_argument("-p", "--print", action="store_true", help="print output")
0xLucqs marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -149,9 +150,17 @@ def main() -> int:

filename = args.filename

if filename is None:
print("No file specified")
return -1

if not os.path.isabs(filename):
filename = os.path.join(os.getcwd(), filename)

if not os.path.exists(filename):
print(f"The specified file doesn't exist: {filename}")
return -1

rule_set_names: List[str] = get_rule_names(args.rules, args.exclude_rules)

results: List[Union[Result, ResultMultiplePositions]]
Expand Down