Add export functionality to codespace commands#4591
Conversation
| "lastUsedAt", | ||
| } | ||
|
|
||
| func (c *Codespace) ExportData(fields []string) *map[string]interface{} { |
There was a problem hiding this comment.
A Go map value is a reference to a hash table, so you almost never need *map types.
There was a problem hiding this comment.
Ah good to know! I will address this across all commands in a followup PR.
| HostPublicKeys []string `json:"hostPublicKeys"` | ||
| } | ||
|
|
||
| var CodespaceFields = []string{ |
There was a problem hiding this comment.
All exported declarations should have a doc comment.
| "github.com/cli/cli/v2/pkg/cmd/codespace/output" | ||
| "github.com/cli/cli/v2/pkg/cmdutil" | ||
| "github.com/cli/cli/v2/pkg/liveshare" | ||
| "github.com/cli/cli/v2/utils" |
There was a problem hiding this comment.
import cliutils "github.com/cli/cli/v2/utils"
Generally, you should never name a package "util".
There was a problem hiding this comment.
Agreed. We've already marked the utils package as "deprecated", meaning that it's pending removal; we just have to extract the still-useful parts of it (table writer, relative time helpers) into their own packages.
| case "label": | ||
| data[f] = pi.Label() | ||
| case "browseUrl": | ||
| data[f] = pi.BrowseURL() |
| "hasUncommitedChanges": c.GitStatus.HasUncommitedChanges, | ||
| } | ||
| default: | ||
| sf := v.FieldByNameFunc(func(s string) bool { |
There was a problem hiding this comment.
What happens when f is misspelled? I suspect the map has an (f, nil) entry. It would be better to log.Fatal.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
There was a problem hiding this comment.
It panics, but the user is not able to pass in misspelled fields because the list of requested fields is always checked against a list of allowed fields.
|
🙂 loving the new functionality. No opinions on the codebase, but curious if we need additional test |
This adds
--jsonand--templateexport functionality togh cs listandgh cs ports.Additionally, it switches
gh cs portstable output to gh's own TablePrinter instead of the tablewriter package.Finally, this was able to remove the obsolete
codespaces/outputpackage.Followup to #4516