Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an option to get rustc to show a "successful" message?

Tags:

rust

When I compile a program using rustc I usually get errors. Once I've eliminated the errors, I get no message which means that compile was successful.

Is there an option to get rustc to show a "successful" message? It would be nice to see positive feedback.

like image 854
Paul McCarthy Avatar asked Feb 14 '21 21:02

Paul McCarthy


1 Answers

Most Rust programmers don't invoke rustc directly, but instead do it through cargo, which prints a green success message for each crate that is compiled:

$ cargo build
   Compiling cfg-if v0.1.10
   Compiling lazy_static v1.4.0
   Compiling bytes v0.5.6
   Compiling mycrate v0.2.0 (/dev/rust/mycrate)
    Finished dev [unoptimized + debuginfo] target(s) in 13.17s

You will also get a progress bar tracking the build process:

$ cargo build
   Compiling cfg-if v0.1.10
   Compiling lazy_static v1.4.0
   Building [====================>      ] 3/4: bytes

rustc is more bare-bones and does not output any success messages. However, you can use && to print a message manually if the compilation was successful:

$ rustc main.rs && echo "Compiled successfully"
Compiled successfully

If you want to get even more fancy, you can use ASCII escape codes to make the message green!

$ rustc main.rs && echo "\033[0;32mCompiled successfully"
Compiled successfully # <- this is green!
like image 103
Ibraheem Ahmed Avatar answered Oct 20 '22 08:10

Ibraheem Ahmed