-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
Implement seq (#45) #63
base: master
Are you sure you want to change the base?
Conversation
sleep/src/main.rs
Outdated
@@ -11,7 +11,7 @@ fn main() { | |||
Some(values) => values, | |||
None => { | |||
eprintln!("sleep: Missing operand.\nTry 'sleep --help' for more information."); | |||
process::exit(1); | |||
process::exit(1);2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be careful with this, remember to check compiling for the whole workspace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay... sorry about that. Must have commited that by accident.
For next commits follow the git commit message guideline please |
seq/src/seq.yml
Outdated
[OPTIONS] <FIRST> <INCREMENT> <LAST> | ||
args: | ||
- FIRST: | ||
help: > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When possible, use single line string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, will apply that to the remaining single help values
seq/src/main.rs
Outdated
|
||
fn next(&mut self) -> Option<Self::Item> { | ||
if self.step.is_sign_positive() && self.current <= self.stop { | ||
let result = self.current.clone(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f64
is Copy
, so you don't need to clone
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood
seq/src/main.rs
Outdated
self.current += self.step; | ||
|
||
Some(result) | ||
} else if self.step.is_sign_negative() && self.current >= self.stop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic of the inside this else if
is the same as the first if
logic, it's that right? If so, you could just use logical OR (||
) on the first if and remove this else if
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I refactored this to be one if condition since they are the same.
seq/src/main.rs
Outdated
|
||
use clap::{load_yaml, App, AppSettings}; | ||
|
||
#[derive(Clone,Debug)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since they are all small Copy
types, you could also derive Copy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okie dokie
Running
Which is expected when creating floating point sequences because of how floating point numbers are added or subtracted. To address this precision loss, I'm planning to use |
4fc24b8
to
d6ba949
Compare
As part of the PR, I have to run the > cargo fmt -p seq
Could not parse TOML: expected an equals, found a newline at line 3 So checking out line 3 of ...
# Could not parse TOML: expected an equals, found a newline at line 3
make_backup
...
# Could not parse TOML: duplicate key: `wrap_comments`
wrap_comments = true
# Could not parse TOML: invalid escape character in string: `y` at line 54
license_template_path = "Copyright {\y} Eric Shimizu Karbstein."
,,,
# invalid type: integer `2018`, expected string for key `edition`
edition = 2018 Commenting those lines, produces an error: Warning: can't set `skip_children = false`, unstable features are only available in nightly channel. I was able to make it run with |
I think it's ok to use nightly just for formatting Also, I'm ok with adding crates when makes sense, and your use makes sense, but try to keep on a minimum |
@GrayJack I'm at a crossroad. Currently looking at implementing I came across runtime-fmt that may be a solution but requires Any suggested direction or idea for my dilemma? |
Still, using printf from c would require unsafe, so I don't think you should use them |
So I should parse the Using this as a reference for the format |
Yeah, I think at one point it will be in the coreutil_core, since |
Sorry I did not understand, what do you mean by "copy&paste plus additions"? |
Copy and paste the formatting code from echo, add the cases that are missing (additions) |
150: Seq: Add --terminator flag r=GrayJack a=reastyn Issue #63 Co-authored-by: Tomas Rokos <[email protected]>
Implement
seq
.Drafted the PR to show progress and any possible early reviews if needed.
TODO:
seq
options--format
--separator
--equal-width