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

3622 chifra when remove list and make it the default remove dependance of timestamps for count option #3623

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
5 changes: 5 additions & 0 deletions sdk/when.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ func (opts *WhenOptions) When() ([]types.NamedBlock, *types.MetaData, error) {
return queryWhen[types.NamedBlock](opts)
}

// WhenList implements the chifra when --list command.
func (opts *WhenOptions) WhenList() ([]types.NamedBlock, *types.MetaData, error) {
return queryWhen[types.NamedBlock](opts)
}

// WhenTimestamps implements the chifra when --timestamps command.
func (opts *WhenOptions) WhenTimestamps() ([]types.Timestamp, *types.MetaData, error) {
return queryWhen[types.Timestamp](opts)
Expand Down
13 changes: 6 additions & 7 deletions src/apps/chifra/internal/when/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ func (opts *WhenOptions) validateWhen() error {
return validate.Usage("chain {0} is not properly configured.", chain)
}

if opts.Count {
opts.Timestamps = true
}

if opts.Timestamps {
if opts.List {
return validate.Usage("Please choose only one of {0}.", "--timestamps or --list")
Expand All @@ -48,10 +52,6 @@ func (opts *WhenOptions) validateWhen() error {
return validate.Usage("The {0} option is only available with the {1} option.", "--deep", "--timestamps --check")
}

if opts.Count {
return validate.Usage("The {0} option is only available with the {1} option.", "--count", "--timestamps")
}

if opts.Update {
return validate.Usage("The {0} option is only available with the {1} option.", "--update", "--timestamps")
}
Expand All @@ -66,9 +66,8 @@ func (opts *WhenOptions) validateWhen() error {
}

if len(opts.Blocks) == 0 {
// If no identifier, then must be either --list or --timestamps
if !opts.List && !opts.Timestamps {
return validate.Usage("Please supply one or more block identifiers or one or more dates.")
if !opts.Timestamps {
opts.List = true
}

} else {
Expand Down
2 changes: 1 addition & 1 deletion src/dev_tools/goMaker/templates/cmd-line-options.csv
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ num,folder,group,route,tool,longName,hotKey,def_val,attributes,option_type,data_
#
27000,tools,Chain Data,when,whenBlock,,,,visible|docs,command,,,Get block dates,[flags] < block | date > [ block... | date... ],default|caching|,Find block(s) based on date&#44; blockNum&#44; timestamp&#44; or 'special'.
27020,tools,Chain Data,when,whenBlock,blocks,,,visible|docs,positional,list<string>,namedBlock,,,,one or more dates&#44; block numbers&#44; hashes&#44; or special named blocks (see notes)
27030,tools,Chain Data,when,whenBlock,list,l,,visible|docs,switch,<boolean>,,,,,export a list of the 'special' blocks
27030,tools,Chain Data,when,whenBlock,list,l,,visible|docs,switch,<boolean>,namedBlock,,,,export a list of the 'special' blocks
27040,tools,Chain Data,when,whenBlock,timestamps,t,,visible|docs,switch,<boolean>,timestamp,,,,display or process timestamps
27050,tools,Chain Data,when,whenBlock,count,U,,visible|docs,switch,<boolean>,timestampCount,,,,with --timestamps only&#44; returns the number of timestamps in the cache
27060,tools,Chain Data,when,whenBlock,truncate,n,NOPOS,,flag,<blknum>,,,,,with --timestamps only&#44; truncates the timestamp file at this block
Expand Down
6 changes: 5 additions & 1 deletion src/dev_tools/goMaker/types/types_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -647,10 +647,14 @@ func (c *Command) HasSdkEndpoints() bool {
}

func (c *Command) ReturnTypes() string {
present := map[string]bool{}
ret := []string{}
for _, op := range c.Options {
if len(op.ReturnType) > 0 {
ret = append(ret, op.RetType())
if !present[op.RetType()] {
ret = append(ret, op.RetType())
}
present[op.RetType()] = true
}
}
return strings.Join(ret, "|\n")
Expand Down
Loading