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: Add "projects list" command to the CLI #333

Merged
merged 3 commits into from
Feb 21, 2022
Merged

feat: Add "projects list" command to the CLI #333

merged 3 commits into from
Feb 21, 2022

Conversation

kylecarbs
Copy link
Member

This adds a WorkspaceOwnerCount parameter returned from the
projects API. It's helpful to display the amount of usage
a specific project has.

@codecov
Copy link

codecov bot commented Feb 19, 2022

Codecov Report

Merging #333 (7250695) into main (59ee22d) will decrease coverage by 0.13%.
The diff coverage is 78.37%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #333      +/-   ##
==========================================
- Coverage   67.44%   67.30%   -0.14%     
==========================================
  Files         142      143       +1     
  Lines        7710     7806      +96     
  Branches       77       77              
==========================================
+ Hits         5200     5254      +54     
- Misses       1981     2014      +33     
- Partials      529      538       +9     
Flag Coverage Δ
unittest-go-macos-latest 66.12% <75.67%> (-0.19%) ⬇️
unittest-go-ubuntu-latest 67.15% <72.97%> (-0.20%) ⬇️
unittest-go-windows-2022 65.76% <75.67%> (+0.02%) ⬆️
unittest-js 63.61% <ø> (ø)
Impacted Files Coverage Δ
cli/root.go 84.61% <ø> (ø)
coderd/projects.go 62.89% <72.22%> (+0.25%) ⬆️
cli/projectlist.go 80.43% <80.43%> (ø)
cli/login.go 55.23% <100.00%> (ø)
cli/projectcreate.go 52.40% <100.00%> (ø)
cli/projects.go 77.41% <100.00%> (+1.14%) ⬆️
cli/workspacecreate.go 47.36% <100.00%> (ø)
peer/conn.go 75.19% <0.00%> (-2.82%) ⬇️
peerbroker/listen.go 82.40% <0.00%> (-2.40%) ⬇️
agent/agent.go 66.08% <0.00%> (-2.18%) ⬇️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 59ee22d...7250695. Read the comment docs.

@kylecarbs kylecarbs force-pushed the projectlist branch 3 times, most recently from 1bd421f to 9efe4ca Compare February 19, 2022 18:44
This adds a WorkspaceOwnerCount parameter returned from the
projects API. It's helpful to display the amount of usage
a specific project has.
@@ -67,7 +67,7 @@ func login() *cobra.Command {
if !isTTY(cmd) {
return xerrors.New("the initial user cannot be created in non-interactive mode. use the API")
}
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "%s Your Coder deployment hasn't been set up!\n", color.HiBlackString(">"))
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "%s Your Coder deployment hasn't been set up!\n", caret)
Copy link
Contributor

Choose a reason for hiding this comment

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

I like factoring out the caret, nice improvement 👍


if len(projects) == 0 {
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "%s No projects found in %s! Create one:\n\n", caret, color.HiWhiteString(organization.Name))
_, _ = fmt.Fprintln(cmd.OutOrStdout(), color.HiMagentaString(" $ coder projects create <directory>\n"))
Copy link
Contributor

Choose a reason for hiding this comment

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

One thing the caret refactoring made me think about is if we'd also want to have a helper for the prompt string $ - mainly because we may want to show something different on Windows. But not a big deal!

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point!

Comment on lines +56 to +57
color.WhiteString("Archive"),
color.WhiteString(project.UpdatedAt.Format("January 2, 2006")),
Copy link
Contributor

Choose a reason for hiding this comment

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

We could log issues to track this missing data, if it's not yet available. Might be good starter issues to on-board other developers here!

Copy link
Member Author

Choose a reason for hiding this comment

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

So this is there, but the formatting string makes it look weird here hahaha. This actually outputs the proper dates!

Comment on lines 31 to +34
// Project is the JSON representation of a Coder project.
// This type matches the database object for now, but is
// abstracted for ease of change later on.
type Project database.Project
type Project struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Neat, looks like some extra fields we can put in the UI table to make it look more interesting now, too!

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed!

@kylecarbs kylecarbs merged commit 67613da into main Feb 21, 2022
@kylecarbs kylecarbs deleted the projectlist branch February 21, 2022 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants