Skip to content

Commit

Permalink
Add buffers to "modules info" command output (#332)
Browse files Browse the repository at this point in the history
  • Loading branch information
asmaloney authored Jul 22, 2023
1 parent b13e7fd commit 9c18a62
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ All notable changes to this project will be documented in this file. The format
### Added

- New command-line command `module` outputs information about modules. Currently includes two subcommands:
- `info [name]` outputs detailed info about a module - name, version, description, and any parameters. `name` can be a space-separated list of modules or `all`.
- `info [name]` outputs detailed info about a module - name, version, description, any buffers, and any parameters. `name` can be a space-separated list of modules or `all`.
- `list` outputs the list of modules - name, version, and description

### Changed
Expand Down
5 changes: 5 additions & 0 deletions actr/modules/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type ModuleInterface interface {
ModuleVersion() string
ModuleDescription() string

HasBuffers() bool
Buffers() buffer.List

HasParameters() bool
Expand All @@ -50,6 +51,10 @@ func (m Module) ModuleDescription() string {
return m.Description
}

func (m Module) HasBuffers() bool {
return len(m.BufferList) > 0
}

func (m Module) Buffers() buffer.List {
return m.BufferList
}
Expand Down
12 changes: 12 additions & 0 deletions cmd/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ func info(args []string) {
fmt.Println(chalk.Header(" Description"))
fmt.Printf(" %s\n", mod.ModuleDescription())

if mod.HasBuffers() {
fmt.Println(chalk.Header(" Buffers"))

writer := tabwriter.NewWriter(os.Stdout, 1, 1, 3, ' ', 0)
for _, buffer := range mod.Buffers() {
fmt.Fprintf(writer, "\t%s", chalk.Italic(buffer.Name))
}
writer.Flush()

fmt.Println("")
}

if mod.HasParameters() {
fmt.Println(chalk.Header(" Parameters"))
params := mod.Parameters()
Expand Down

0 comments on commit 9c18a62

Please sign in to comment.