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

Tutorial: Draft of Output chapter #52

Merged
merged 2 commits into from
Jul 31, 2018

Conversation

killercup
Copy link
Collaborator

No description provided.

For this, you should try to printing useful status updates,
ideally in a form that can be easily consumed.

Using the [indicatif] crate,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we only want to mention one crate here or maybe also link to https://github.com/FGRibreau/spinners (it has a shark spinner! 🦈 )

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wanted to expand this with an example that uses indicatif to show progress as well as log messages. The spinners crate can't do that afaik


will print

> My lucky number is 42.

Choose a reason for hiding this comment

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

supernit: you can use ```console

So it looks like this:

My lucky number is 42.

Choose a reason for hiding this comment

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

Same below

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I <3 super nits, thanks!

env_logger?

</aside>

Choose a reason for hiding this comment

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

Add TODO for escaping symbols in stdout/stderr?

Maybe it needs a tracking issue first, in particular I'm getting problems piping ssh to the stdout and stderr of my Rust program, it breaks the terminal (macOS standard Terminal.app) state quite often and I have to fix it like that:

$ stty sane

But ideally I need to figure what symbols cause that and how to escape them…

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, I hadn't heard of that. Can you open an issue? One goal of the issue might be to add a section to the book :)

Choose a reason for hiding this comment

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

Sure, here we go #57

@killercup
Copy link
Collaborator Author

I'll merge this and will expand it in future PRs!

@killercup killercup merged commit 30b5c2f into rust-cli:master Jul 31, 2018
Copy link
Collaborator

@spacekookie spacekookie left a comment

Choose a reason for hiding this comment

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

I complained a bit more as requested 😬

but also a special syntax.
It expects you to write,
as a first parameter,
a literal string that with placeholders,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This sentence is a bit clunky.

"It expects you to write a string literal as the first parameter, that contains placeholders that will be filled in [...]"

For numbers and strings this works very well,
but not all types can do that.
This is why there is also a "debug representation",
that you can get by filling the braces of the placeholder like this: `{:?}`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

There are many more od these, maybe we want to link to the section in the book where they're explained?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

there's a link to the std::fmt docs in the very next aside


**TODO:**
crate for actual log output -- which one?
env_logger?
Copy link
Collaborator

Choose a reason for hiding this comment

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

We might want to include several and compare? The book is supposed to be curated content, right? So maybe keeping a list of actively developed loggers isn't a bad idea

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right, but this is also the tutorial. I'll add a todo to link to ../in-depth/human-communication.html :)

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.

3 participants