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

Add quiet (-q|--quiet) mode to suppress Ctrl+D banner #39

Merged
merged 1 commit into from
Jan 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 🎯 [Unreleased]
### Added
- Quiet (-q|--quiet) mode to suppress Ctrl+D banner: 'Press Ctrl+D to end recording' [pull/39]

## [0.4.2] - 2021-01-04
### Added
Expand Down Expand Up @@ -108,4 +110,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Generating a gif out of n frames of a recording
- CI pipeline as GitHub Actions workflow

[issue/4]: https://github.com/sassman/t-rec-rs/issues/4
[issue/4]: https://github.com/sassman/t-rec-rs/issues/4
7 changes: 7 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ pub fn launch<'a>() -> ArgMatches<'a> {
.required(false)
.help("Enable verbose insights for the curious.")
)
.arg(Arg::with_name("quiet")
.takes_value(false)
.short("q")
.long("quiet")
.required(false)
.help("Quiet mode, suppresses the banner: 'Press Ctrl+D to end recording'")
)
.arg(
Arg::with_name("decor")
.takes_value(true)
Expand Down
6 changes: 5 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ fn main() -> Result<()> {
println!("Recording window id: {}", win_id);
}
}
println!("Press Ctrl+D to end recording");
if args.is_present("quiet") {
println!();
Copy link

Choose a reason for hiding this comment

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

Do we need to println!() at all? Do we need the extra \n?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I tried to express this in the commit message, "an empty string is outputted as the
application needs there to be something to begin recording".

Without it, there is no recording and the following output:

$ t-rec -q
[src/common/identify_transparency.rs:24] margin.top = 0
[src/common/identify_transparency.rs:34] margin.bottom = 0
[src/common/identify_transparency.rs:44] margin.left = 0
[src/common/identify_transparency.rs:54] margin.right = 0
$ echo $?
0

Copy link
Owner

Choose a reason for hiding this comment

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

Instead of println!(); you could use print!("{esc}[H", esc = 27 as char); that seems to work too.

The dbg output might be something that I forgot to remove.. in src/common/identify_transparency.rs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're the boss, but that doesn't seem to work for me. Exhibits the same behaviour as no print at all. println!("{esc}[H", esc = 27 as char); works, would you prefer that to println!()?

Copy link
Owner

Choose a reason for hiding this comment

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

hm, interesting. What happens in your case? The recording does not start at all?

Copy link
Owner

Choose a reason for hiding this comment

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

I'm fine with the empty line for now, I don't mind. A future goal is to have a little count down indicating that the recording will start in 3, 2, 1 - <clear> So that a user gets feedback that it worked, and has 3 seconds to prepare and the recording will start on a clear screen.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hm, interesting. What happens in your case? The recording does not start at all?

Nested t-rec didn't work very well... but yes. No attempt to record with that, just exit out (with the debug):

t-rec

Copy link
Contributor Author

Choose a reason for hiding this comment

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

println!(); doesn't actually output a new line on the recorded screen:
t-rec

Copy link
Owner

Choose a reason for hiding this comment

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

Good to know, anyway the other issue that the recording does not start then is something I will dig into.
But as far as this PR is concerned the new line is fine for me.

} else {
println!("Press Ctrl+D to end recording");
}
thread::sleep(Duration::from_millis(1250));
clear_screen();

Expand Down