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

fix: test vector help text #657

Merged
merged 1 commit into from
Sep 1, 2024
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 Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ PROJECT_ROOT := $(abspath $(dir $(abspath $(lastword $(MAKEFILE_LIST)))))

# This finds all Dafny projects in this repository
# This makes building root level targets for each project easy
PROJECTS = $(shell find . -mindepth 2 -maxdepth 2 -type f -name "Makefile" | xargs dirname | xargs basename)
PROJECTS = $(shell find . -mindepth 2 -maxdepth 2 -type f -name "Makefile" | fgrep -v smithy-dafny | xargs dirname | xargs basename)

verify:
$(foreach PROJECT, $(PROJECTS), \
Expand Down
29 changes: 19 additions & 10 deletions StandardLibrary/src/GetOpt.dfy
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,15 @@ module {:options "-functionSyntax:4"} GetOpt {
}
}

predicate IsHelp(args : Parsed)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer Help?

{
&& |args.params| != 0
&& args.params[0].name == HELP_STR
}

function {:tailrecursion} NeedsHelp(opts : Options, args : Parsed, prefix : string := "") : Option<string>
{
if |args.params| != 0 && args.params[0].name == HELP_STR then
if IsHelp(args) then
Some(GetHelp(opts, prefix))
else if args.subcommand.Some? then
var pos :- GetSubOptions(opts.params, args.subcommand.value.command);
Expand Down Expand Up @@ -613,16 +619,19 @@ module {:options "-functionSyntax:4"} GetOpt {

function /*{:tailrecursion}*/ PostProcess(opts : Options, args : Parsed) : Result<Parsed, string>
{
var newParams :- PostProcess2(opts.params, args.params);
if args.subcommand.Some? then
var optPos := GetSubOptions(opts.params, args.subcommand.value.command);
if optPos.Some? then
var sub :- PostProcess(opts.params[optPos.value].options, args.subcommand.value);
Success(args.(params := args.params + newParams, subcommand := Some(sub)))
else
Failure("Internal error in GetOpt::PostProcess")
if IsHelp(args) then
Success(args)
else
Success(args.(params := args.params + newParams))
var newParams :- PostProcess2(opts.params, args.params);
if args.subcommand.Some? then
var optPos := GetSubOptions(opts.params, args.subcommand.value.command);
if optPos.Some? then
var sub :- PostProcess(opts.params[optPos.value].options, args.subcommand.value);
Success(args.(params := args.params + newParams, subcommand := Some(sub)))
else
Failure("Internal error in GetOpt::PostProcess")
else
Success(args.(params := args.params + newParams))
}

predicate AllDigits(s : string)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ module {:options "-functionSyntax:4"} WrappedMaterialProvidersMain {
var parsedOptions? := GetOptions(vectorOptions, args);

if parsedOptions?.Success? {
var h := NeedsHelp(vectorOptions, parsedOptions?.value);
if h.Some? {
print h.value;
return;
}
var op? := ParseCommandLineOptions(parsedOptions?.value);

if op?.Success? {
Expand Down
Loading