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 portup #19

Merged
merged 1 commit into from
Dec 24, 2023
Merged

add portup #19

merged 1 commit into from
Dec 24, 2023

Conversation

alessio
Copy link
Owner

@alessio alessio commented Dec 24, 2023

Summary by CodeRabbit

  • New Features

    • Introduced portup, a new command-line tool for updating and upgrading MacPorts packages.
    • Users can now display help information and version details directly from the command line.
    • Added an option to automatically run a reclaim process after upgrading packages to clean up unnecessary files.
  • Documentation

    • Provided usage instructions for new command-line options within the tool.

Copy link
Contributor

coderabbitai bot commented Dec 24, 2023

Walkthrough

Walkthrough

The portup command-line tool has been introduced for managing package updates via MacPorts. It streamlines the process by adding functionalities for help, version info, and cleaning up after package upgrades. The main entry point and helper functions for executing MacPorts commands, handling logs, and providing usage instructions have been implemented.

Changes

File Change Summary
cmd/portup/main.go Added main functionality for the portup CLI tool, including support for help and version commands, and a routine to clean up after package updates.

🐇✨
To the ports we hop, a quick update run,
Through the lines of code, the portup begun.
With each command we leap, and outdated we shun,
A tidy MacPorts, our mission is done. 🌟🚀
🐇✨

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • You can directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
  • You can tag CodeRabbit on specific lines of code or entire files in the PR by tagging @coderabbitai in a comment. Examples:
    • @coderabbitai generate unit tests for this file
    • @coderabbitai modularize this function
  • You can tag @coderabbitai in a PR comment and ask questions about the PR and the codebase. Use quoted replies to pass the context for follow-up questions. Examples:
    • @coderabbitai gather interesting statistics about this repository and render them in a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai generate unit tests for the src/utils.ts file.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@alessio alessio merged commit 21cc290 into main Dec 24, 2023
3 checks passed
@alessio alessio deleted the portup branch December 24, 2023 04:12
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 57f1e14 and f1e0178.
Files selected for processing (1)
  • cmd/portup/main.go (1 hunks)
Additional comments: 7
cmd/portup/main.go (7)
  • 31-32:
    The -v flag is correctly set for versionMode, providing a shorthand for version information.

  • 33-33:
    The runReclaim flag is correctly defined, enabling the reclaim process after upgrading outdated packages.

  • 35-36:
    The flag.Usage is properly set to the custom usage function, and the output is correctly directed to os.Stderr.

  • 75-81:
    The runPortCommand function is well-implemented, logging the command to be executed and running it while directing the output to the appropriate file descriptors.

  • 84-90:
    The openLogFile function correctly opens a log file with appropriate file permissions and modes.

  • 93-102:
    The usage function properly prints the usage information to os.Stderr and ignores errors from fmt.Fprintf, which is acceptable in this context.

  • 104-116:
    The handleHelpAndVersionModes function correctly handles the help and version modes and exits the program after displaying the relevant information.

Comment on lines +29 to +30
flag.BoolVar(&helpMode, "help", false, "display this help and exit.")
flag.BoolVar(&helpMode, "h", false, "")
Copy link
Contributor

Choose a reason for hiding this comment

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

There seems to be a logical error with the flag definitions for helpMode. The -h flag is also setting helpMode instead of a separate flag for shorthand help.

- flag.BoolVar(&helpMode, "h", false, "")
+ flag.BoolVar(&helpMode, "h", false, "display this help and exit (shorthand).")

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
flag.BoolVar(&helpMode, "help", false, "display this help and exit.")
flag.BoolVar(&helpMode, "h", false, "")
flag.BoolVar(&helpMode, "help", false, "display this help and exit.")
flag.BoolVar(&helpMode, "h", false, "display this help and exit (shorthand).")

Comment on lines +47 to +50
if len(flag.Args()) > 0 {
logfile, err := openLogFile(flag.Arg(0))
if err != nil {
log.Fatalf("couldn't open the file %s: %v", flag.Arg(0), err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding error handling for the case where more than one argument is provided, as the current implementation assumes only one argument for the log file path.

+ if len(flag.Args()) > 1 {
+     log.Fatalf("unexpected number of arguments: want 0 or 1, got %d", len(flag.Args()))
+ }

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
if len(flag.Args()) > 0 {
logfile, err := openLogFile(flag.Arg(0))
if err != nil {
log.Fatalf("couldn't open the file %s: %v", flag.Arg(0), err)
if len(flag.Args()) > 1 {
log.Fatalf("unexpected number of arguments: want 0 or 1, got %d", len(flag.Args()))
}
if len(flag.Args()) > 0 {
logfile, err := openLogFile(flag.Arg(0))
if err != nil {
log.Fatalf("couldn't open the file %s: %v", flag.Arg(0), err)

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.

1 participant