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

Big refactor #57

Merged
merged 20 commits into from May 4, 2020
Merged

Big refactor #57

merged 20 commits into from May 4, 2020

Conversation

tversteeg
Copy link
Owner

@tversteeg tversteeg commented May 1, 2020

Changes:

  • Every package manager has its own file in src/package_manager/. All you have to do to create a new one is copy another, change the values & add it to src/package_manager/mod.rs.
  • .emplace file now has a field for flags and a slightly different format.
  • Old .emplace files are automatically migrated to the new version.
  • PipUser and Pip3User are not used anymore, they are handled by Pip & Pip3 with flags.
  • Rename RustupComponent to Rustup.
  • The Regex parser is replaced by a manual parser which is generic.
  • Default console output is a regular print instead of a info! which prints a timestamp.

TODO for this PR:

  • Implement prefix for commands (Nix).
  • Support non-determined flag values (Nix).
  • Support sub commands with multiple arguments (Rustup).

TODO later:

  • Check for the command in the path instead of executing it (Fix polling of installtion programm. Fix yay #56).
  • Add known flags with values for Pacman.
  • Add known flags with values for Pip.
  • Add known flags with values for Pip3.
  • Add known flags with values for Yay.
  • Add known flags with values for Snap.
  • Add known flags with values for Npm.
  • Add known flags with values for Nix.
  • Add known flags with values for Rua.
  • Add known flags with values for Chocolatey.
  • Add known flags with values for Scoop.

@tversteeg
Copy link
Owner Author

No idea why I can't select you in the reviewers dropdown, but @0xd34b33f, @filalex77 & @lberrymage, could you review this?

@tversteeg tversteeg marked this pull request as ready for review May 3, 2020 13:30
@Br1ght0ne
Copy link
Contributor

@tversteeg Okay, this is big. I'll take a look later today.

.map(|package| package.color_full_name())
// Make it a vector again
.collect::<_>();
let package_names: Vec<&str> = package_names
Copy link
Contributor

Choose a reason for hiding this comment

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

Needless collect. Just call map(|x| x.as_str())

Copy link
Owner Author

Choose a reason for hiding this comment

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

Unfortunately I can't, because when I try to convert it to a &str the original String goes out of scope and gets deleted.

// First we split the line into separating characters
let lines = line
.split(|c| c == ';' || c == '|' || c == '&')
// Then try to find the proper package manager for each line, this also filters out
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice solution! And much faster, then regexes. But it can be a lot of tricky moments, a-la bash -c 'cargo install package'. So maybe we need to use something like this. Or it's an overkill (:

Copy link
Owner Author

@tversteeg tversteeg May 3, 2020

Choose a reason for hiding this comment

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

Nice solution! And much faster, then regexes. But it can be a lot of tricky moments, a-la bash -c 'cargo install package'. So maybe we need to use something like this. Or it's an overkill (:

Actually catching bash -c 'cargo install package' isn't a bad idea right?

So maybe we need to use something like this. Or it's an overkill (:

I was considering this as well but I also want to support different shells..

info!("Commiting with message \"{}\".", commit_msg);
git::add_file(&self.path, &*self.config.repo.file, false)?;
git::commit_all(&self.path, &*commit_msg, false, false)?;
println!("Commiting with message \"{}\".", commit_msg);
Copy link
Contributor

Choose a reason for hiding this comment

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

why println, if there's info! macro?

Copy link
Owner Author

Choose a reason for hiding this comment

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

The info macro prints useless timestamps into the console.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's easily tweakable using fern crate. We can leave info and create verbosity switcher to show messages with different priority.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Ok I'll first merge this and implement that afterwards.

src/repo.rs Show resolved Hide resolved
@tversteeg
Copy link
Owner Author

@all-contributors please add @0xd34b33f for review

@allcontributors

This comment has been minimized.

Copy link
Contributor

@Br1ght0ne Br1ght0ne left a comment

Choose a reason for hiding this comment

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

Okay, so I spent a solid half hour with this PR, and I must say - your code is very readable and enjoyable. I appreciate all the comments. Nothing serious stood out, just a nitpick. I'd be happy to review more!

src/history.rs Outdated Show resolved Hide resolved
@lberrymage
Copy link
Contributor

I'll be leaving a review later today; like filalex77 said, there's quite a bit to go through!

@tversteeg
Copy link
Owner Author

@lberrymage no problem take your time, I still have to implement multi-argument sub-commands which I'll do tomorrow if I'll have time.

After that I'll merge this and create an alpha release version so the changes can be used for a while.

@tversteeg
Copy link
Owner Author

@all-contributors please add @filalex77 for review

@allcontributors

This comment has been minimized.

@tversteeg tversteeg mentioned this pull request May 3, 2020
@tversteeg tversteeg merged commit bb5ac35 into master May 4, 2020
@tversteeg tversteeg deleted the catch-refactor branch May 4, 2020 16:20
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.

None yet

4 participants