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

Print the format type when the format is in an incorrent position #84

Merged
merged 2 commits into from
Oct 14, 2021
Merged

Conversation

boozec
Copy link
Contributor

@boozec boozec commented Oct 8, 2021

When it raises an error caused by position of the format, now prints the format type as string instead of the position inside the array of formats.
In this way you can read on stdout the type like .tar or .lz instead of 1, 2, .., n.

Example

Current code:

$ ./target/debug/ouch c hello.txt archive.tar.lz.tar.lz
[ERROR] Cannot compress to 'archive.tar.lz.tar.lz'.
 - Found the format '1' in an incorrect position.
 - 1 can only be used at the start of the file extension.

hint: If you wish to compress multiple files, start the extension with 1.
hint: Otherwise, remove 1 from 'archive.tar.lz.tar.lz'.

What fixs this PR:

$ ./target/debug/ouch c hello.txt archive.tar.lz.tar.lz
[ERROR] Cannot compress to 'archive.tar.lz.tar.lz'.
 - Found the format '.lz' in an incorrect position.
 - '.lz' can only be used at the start of the file extension.

hint: If you wish to compress multiple files, start the extension with '.lz'.
hint: Otherwise, remove '.lz' from 'archive.tar.lz.tar.lz'.

@marcospb19
Copy link
Member

Thanks for opening a PR!

@marcospb19
Copy link
Member

marcospb19 commented Oct 10, 2021

The new message:

[ERROR] Cannot compress to 'archive.tar.lz.tar.lz'.
- Found the format '.lz' in an incorrect position.
- '.lz' can only be used at the start of the file extension.

The error message expected would be:

> [ERROR] Cannot compress to 'archive.tar.lz.tar.lz'.
> - Found the format '.tar' in an incorrect position.
> - '.tar' can only be used at the start of the file extension.

And this would be referring only to the second .tar part, because it makes no sense creating a tar archive with only one file, we made it into an error (but maybe it shouldn't be? What do you think??).

src/commands.rs Outdated Show resolved Hide resolved
When it raises an error caused by position of the format, now prints
the format type as string instead of the position inside the array of
formats.
In this way you can read on stdout the type like `.tar` or `.lz` instead
of `1`, `2`, .., `n`.
@marcospb19
Copy link
Member

Resolved conflicts, ready to merge (waiting for CI).

@marcospb19 marcospb19 added hacktoberfest-accepted Tag PR as accepted for the hacktoberfest event bugfix Fixes an existing bug labels Oct 14, 2021
@marcospb19
Copy link
Member

Moved pending discussion about the conflicting error messages to #88.

@marcospb19 marcospb19 merged commit 1c24f41 into ouch-org:master Oct 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Fixes an existing bug hacktoberfest-accepted Tag PR as accepted for the hacktoberfest event
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants