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

Accept input via command chaining #45

Open
jthurman42 opened this issue Feb 21, 2020 · 4 comments
Open

Accept input via command chaining #45

jthurman42 opened this issue Feb 21, 2020 · 4 comments
Labels
enhancement New feature or request nr-cli priority:high Triaged as a high size:L Large

Comments

@jthurman42
Copy link
Contributor

jthurman42 commented Feb 21, 2020

Feature Description

Add the ability to chain newrelic commands together, example would be an entity search filtered to GUIDs, then piped back to newrelic to add tags to all of those entities.

$ newrelic entity search --name "mystuff" --only-attributes entityId | \
  newrelic entity tags add --tag owner:me
@jthurman42 jthurman42 added the enhancement New feature or request label Feb 21, 2020
@jthurman42 jthurman42 added this to Backlog in NR1 Developer Toolkit Community via automation Feb 21, 2020
@jthurman42 jthurman42 added priority:high Triaged as a high size:L Large labels Mar 2, 2020
nicolasjhampton added a commit to nicolasjhampton/newrelic-cli that referenced this issue Aug 31, 2020
This PR adds utility methods and logic to read stdin
for details needed in commands, allowing each command
ouput to be piped to the next command

newrelic#45
@nicolasjhampton
Copy link
Contributor

@jthurman42 I intend to start tackling this issue, using the entity command as an MVP, but it would help if you could answer a question. This example code includes a secret request to add a feature for bulk edits. Currently in the cli, there's no way to specify multiple entities to act on at once. Should I aim here to add that functionality?

@jthurman42
Copy link
Contributor Author

@nicolasjhampton Good point, there is an assumption that the CLI would handle an array of input items and loop thought them based on the example. I believe my thought here was that the data passed through the pipe would be in JSON, so easy enough to detect an array to iterate on. I'd prefer to see that at least though of, otherwise we're pushing the work of splitting / running multiple items out to the user.

nicolasjhampton added a commit to nicolasjhampton/newrelic-cli that referenced this issue Sep 1, 2020
This PR adds utility methods and logic to read stdin
for details needed in commands, allowing each command
ouput to be piped to the next command

newrelic#45
@nicolasjhampton
Copy link
Contributor

@jthurman42 I've gotten all the way to getting bulk information from stdin to the actual newrelic client query, but there's literally not a method on the newrelic-client-go package that takes several guids and returns the tags for all of them.

Like we agreed before, this is actually two legs of work. I think I'm complete on getting bulk data from stdin and making it accessible to each command to use. If I can get your signoff for this to be reviewed and merged separately, I'll do an inventory of what needs to change in newrelic-client-go to allow useful bulk actions and make a PR there to make further work here possible.

nicolasjhampton added a commit to nicolasjhampton/newrelic-cli that referenced this issue Sep 18, 2020
This PR adds utility methods and logic to read stdin
for details needed in commands, allowing each command
ouput to be piped to the next command

newrelic#45

refactor(release): WIP clean up logic in init function

This commit refactors the init logic to be cleaner, handle
more flags, and prepare for bulk actions

feat(release): WIP collect values from multiple results and add tests

This commit adds more testing and allows reading values from multiple
results

refactor(release): WIP create pipe module

This commit pulls the pipe input logic out of the utils module
and into a new pipe module. It also abstracts the PipeInput map
from other modules.

feat(release): make newrelic entity tags get cmd take stdin

This commit is the last step I can take towards making the
entity tags get command return bulk data based on stdin. Work
has to be done on newrelic-client-go in order to support bulk
guid queries

https://github.com/newrelic/newrelic-client-go/blob/13ed6ee7fa172cce9218cf30e98eab6e1805541d/pkg/entities/tags.go#L124

fix(release): make Get and GetInput always return same values

This commit checks for the existence of the pipeInput internal
state, so even if GetInput is called more than once, nothing is
overwritten and Get returns the same values. More testing and
test refactors are also included.
nicolasjhampton added a commit to nicolasjhampton/newrelic-cli that referenced this issue Sep 18, 2020
This PR adds utility methods and logic to read stdin
for details needed in commands, allowing each command
ouput to be piped to the next command

newrelic#45

refactor(release): WIP clean up logic in init function

This commit refactors the init logic to be cleaner, handle
more flags, and prepare for bulk actions

feat(release): WIP collect values from multiple results and add tests

This commit adds more testing and allows reading values from multiple
results

refactor(release): WIP create pipe module

This commit pulls the pipe input logic out of the utils module
and into a new pipe module. It also abstracts the PipeInput map
from other modules.

feat(release): make newrelic entity tags get cmd take stdin

This commit is the last step I can take towards making the
entity tags get command return bulk data based on stdin. Work
has to be done on newrelic-client-go in order to support bulk
guid queries

https://github.com/newrelic/newrelic-client-go/blob/13ed6ee7fa172cce9218cf30e98eab6e1805541d/pkg/entities/tags.go#L124

fix(release): make Get and GetInput always return same values

This commit checks for the existence of the pipeInput internal
state, so even if GetInput is called more than once, nothing is
overwritten and Get returns the same values. More testing and
test refactors are also included.

docs(release): add docs comments to pipe package
nicolasjhampton added a commit to nicolasjhampton/newrelic-cli that referenced this issue Sep 20, 2020
This PR adds utility methods and logic to read stdin
for details needed in commands, allowing each command
ouput to be piped to the next command

newrelic#45

refactor(release): WIP clean up logic in init function

This commit refactors the init logic to be cleaner, handle
more flags, and prepare for bulk actions

feat(release): WIP collect values from multiple results and add tests

This commit adds more testing and allows reading values from multiple
results

refactor(release): WIP create pipe module

This commit pulls the pipe input logic out of the utils module
and into a new pipe module. It also abstracts the PipeInput map
from other modules.

feat(release): make newrelic entity tags get cmd take stdin

This commit is the last step I can take towards making the
entity tags get command return bulk data based on stdin. Work
has to be done on newrelic-client-go in order to support bulk
guid queries

https://github.com/newrelic/newrelic-client-go/blob/13ed6ee7fa172cce9218cf30e98eab6e1805541d/pkg/entities/tags.go#L124

fix(release): make Get and GetInput always return same values

This commit checks for the existence of the pipeInput internal
state, so even if GetInput is called more than once, nothing is
overwritten and Get returns the same values. More testing and
test refactors are also included.

docs(release): add docs comments to pipe package

docs(release): fix spelling errors
zlesnr added a commit that referenced this issue Sep 21, 2020
…tag-cmd

feat(release): Issue #45 add support for command chaining
@jpvajda jpvajda added the nr-cli label May 24, 2021
@Julien4218
Copy link
Contributor

cc @kidk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request nr-cli priority:high Triaged as a high size:L Large
Projects
No open projects
Development

No branches or pull requests

4 participants