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
When you run ockam enroll and then run ockam project ticket you get the following output displayed to stdout:
✔ Created enrollment ticket. You can use it to enroll another machine using: ockam project enroll
7b226f6e655f74696d655f636f6465223a226336653736343166366631626462346161396635386431306537356635626...646d696e222c2273636f7065223a225370616365227d5d7d7d
After the first line (which is output to stderr), the long string (which is base 64 encoded JSON) is output to stdout. This can be redirected to a file as well (ockam project ticket > ticket.txt). Or saved to an environment variable (TICKET=$(ockam project ticket)), for later use by ockam ticket enroll.
Desired behavior
In addition to displaying the HEX string to stdout (using opts.terminal.stdout().plain()), also display the JSON blob to stderr (using opts.terminal.write_line()).
Here's an example of how this is used.
opts.terminal.write_line(/* json output */)?;
This ensures that the display of the JSON blob is visible to the end user (since it is output to stderr).
Piping to file and saving to env var still works, since opts.terminal.write_line() takes care of not polluting stdout.
The HEX string is actually output to stdout, so that it can be redirected to a file, or saved to a file, or saved to an env var. So ockam project ticket > ticket.txt or TICKET=$(ockam project ticket) will still work.
The opts.terminal.write_line() function does nothing when it detects that the terminal is not interactive. And this prevents this output from ending up in an env var or file (via redirect).
Bonus behavior
The ockam enroll command copies a one-time code that is generated to the clipboard. Here's the code for this.
Use the same mechanism to copy the HEX string when ockam project ticket is run and the base 64 encoded string is displayed to stdout:
Display the normal base64 output to stdout.
Also copy it to the clipboard (and let the user know that it is copied to the clipboard, if that succeeded). You can follow the example in ockam enroll to do this.
nazmulidris
changed the title
Output for ockam project ticket is improved and information is not opaque
Output for ockam project ticket is improved and information is not opaque
Jan 29, 2024
@devanbenz That's awesome, this is all yours. Please let us know if you have any questions as you explore. You can also ask questions on the contributors discord https://discord.ockam.io
Current behavior
When you run
ockam enroll
and then runockam project ticket
you get the following output displayed to stdout:After the first line (which is output to stderr), the long string (which is base 64 encoded JSON) is output to stdout. This can be redirected to a file as well (
ockam project ticket > ticket.txt
). Or saved to an environment variable (TICKET=$(ockam project ticket)
), for later use byockam ticket enroll
.Desired behavior
In addition to displaying the HEX string to stdout (using
opts.terminal.stdout().plain()
), also display the JSON blob to stderr (usingopts.terminal.write_line()
).Here's an example of how this is used.
opts.terminal.write_line()
takes care of not polluting stdout.ockam project ticket > ticket.txt
orTICKET=$(ockam project ticket)
will still work.Bonus behavior
The
ockam enroll
command copies a one-time code that is generated to the clipboard. Here's the code for this.Use the same mechanism to copy the HEX string when
ockam project ticket
is run and the base 64 encoded string is displayed to stdout:ockam enroll
to do this.Here's the code to implement the
ockam project ticket
command: https://github.com/build-trust/ockam/blob/develop/implementations/rust/ockam/ockam_command/src/project/ticket.rs#L97The text was updated successfully, but these errors were encountered: