You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.
❯ dep status -f='{{.Constraint}} '
parse-constraints-with-dash-in-pre ^1.11.0 master ^1.0.0 v2 master ^0.3.0 master master ^0.8.0 master master master master
Then I want to do some logic with it:
dep status -f='{{if eq .Constraint "master"}}{{.ProjectRoot}}{{end}}'
template: status:1:5: executing "status" at <eq .Constraint "mast...>: error calling eq: invalid type for comparison
template: status:1:5: executing "status" at <eq .Constraint "mast...>: error calling eq: invalid type for comparison
Observations
It appears that the template fields Constraint, Version, and Latest suffer this problem becuase of their type declairation because of the type definition of BasicStatus. The fix would be to get convert these to a string before putting in the template. I can send the PR for this.
(Note: You can actually get this to work by running dep status -f='{{if eq .Constraint.String "master"}}{{.Version}}{{end}}'. This isn't that straight forward though.)
The text was updated successfully, but these errors were encountered:
Hi, thanks for trying it out and opening this issue. We have implemented status template output but its usage it not documented (#1497) and I think we can improve the implementation by fixing the issues you posted above. This would also help in clearly documenting the usage.
The fix would be to get convert these to a string before putting in the template. I can send the PR for this.
Thanks for digging into the issue. A PR would be great. Right now, since we use the fields in BasicStatus to calculate constraint, versions, etc, changing field types to string would break them. I think we can introduce another struct type with string as the values for all the fields. And this can also go into the documentation about template usage, keeping the underlying BasicStatus struct hidden.
Perfect. I'll do that. I'll can get the documentation in for #1497 too. I was thinking of putting a couple line message in the dep status -help output. Anywhere else you think it should be documented?
@zkry Sorry for the delay. Yes, we should document it in status help output with all the available fields and I think we should have an examples flag for status, similar to dep ensure -examples where it would show a few examples of how to use the templates.
And maybe we could have more extensive documentation in a dedicate documentation page under docs/status.md in the future. I'll open a separate issue for it.
What version of
dep
are you using (dep version
)?Note: Running
dep status
normally:What
dep
command did you run?First I run:
Then I want to do some logic with it:
What did you expect to see?
The list of projects with constraint as
master
.What did you see instead?
Observations
It appears that the template fields Constraint, Version, and Latest suffer this problem becuase of their type declairation because of the type definition of BasicStatus. The fix would be to get convert these to a string before putting in the template. I can send the PR for this.
(Note: You can actually get this to work by running
dep status -f='{{if eq .Constraint.String "master"}}{{.Version}}{{end}}'
. This isn't that straight forward though.)The text was updated successfully, but these errors were encountered: