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 easy-to-use CLI features #72

Open
StringKe opened this issue Dec 11, 2023 · 7 comments
Open

add easy-to-use CLI features #72

StringKe opened this issue Dec 11, 2023 · 7 comments
Labels
enhancement New feature or request scope: cli

Comments

@StringKe
Copy link

  1. Automatically catch exceptions and create URLs where issues can be submitted
  2. Provide some non-privacy related data collection for refining parsing rules
  3. cli support i18n and configuring memory
@pionxzh pionxzh added the enhancement New feature or request label Dec 11, 2023
@pionxzh
Copy link
Owner

pionxzh commented Dec 11, 2023

For 2, you mean like collecting what rules users tend to enable?

For 3, I don't have any plan to do i18n on CLI tbh 🤔

@StringKe
Copy link
Author

For 2, you mean like collecting what rules users tend to enable?

yes, or collect some minimal chunks of code that have not been hit by any rule for updating new rules.

It can also be used, for example, for packaged code that is not known but can be identified as a jsx (known component).

@pionxzh
Copy link
Owner

pionxzh commented Dec 11, 2023

For the memory part, I would like to implement a size checker before running. If the file size exceeds a limit, the tool will ask you to confirm, with a hint that guides users on how to configure the memory limit to prevent OOM.

@0xdevalias
Copy link

or collect some minimal chunks of code that have not been hit by any rule for updating new rules

This part sounds like it could be rather hard to automate; it seems like the kind of thing that would be better suited to being done manually; but perhaps a special issue template could be added to help guide users with the right info to provide for it:

@pionxzh
Copy link
Owner

pionxzh commented Dec 11, 2023

I think the simple solution is to add a contribution guide and an issue template like what @0xdevalias said. Collecting code snippets anonymously seems impossible.

@0xdevalias
Copy link

There are a few basic CLI type patterns that could potentially be done to 'guide' the user towards creating an issue; and prefilling some of the information as well. I haven't deeply explored it, but here is a quick high level ChatGPT query/response for it:

Details

My Prompt

For a CLI written in node, I want to be able to make it easy for end users to open relevant GitHub issues for bugs/etc.

  • How could I go about implementing this?
  • Are there any standard patterns for how other tools do it?
  • Are there any libraries that can help me?

ChatGPT's Response

To implement a feature in your Node.js CLI application that allows end users to easily open relevant GitHub issues for bugs or other concerns, you can follow these steps:

Steps to Implement the Feature

  1. Capture Error Information: When an error or issue occurs in your application, capture relevant details such as the error message, stack trace, and any specific application context.

  2. Prompt the User: When an error is detected, prompt the user with an option to report the issue. You can use libraries like inquirer.js for interactive CLI prompts.

  3. Format Issue Details: Format the captured error information into a readable and useful format for the issue report.

  4. Generate GitHub Issue URL: Create a URL to open a new issue on your GitHub repository, prefilling details using query parameters. The URL format is:

    https://github.com/[username]/[repository]/issues/new?title=[issue_title]&body=[issue_body]
    
  5. Open the URL in User’s Browser: Use a Node.js library like open to open the generated URL in the user's default web browser.

Example Code Snippet

const open = require('open');
const inquirer = require('inquirer');

function reportIssue(error) {
  const issueTitle = encodeURIComponent("Bug Report: " + error.message);
  const issueBody = encodeURIComponent("Error Details:\n" + error.stack + "\n\nContext:\n...");

  const githubUrl = `https://github.com/yourusername/yourrepo/issues/new?title=${issueTitle}&body=${issueBody}`;

  inquirer.prompt([{
    type: 'confirm',
    name: 'openIssue',
    message: 'Would you like to report this issue to GitHub?',
  }]).then(answers => {
    if (answers.openIssue) {
      open(githubUrl);
    }
  });
}

// Example usage
try {
  // Your code logic
} catch (error) {
  reportIssue(error);
}

Standard Patterns and Libraries

  • Libraries: inquirer.js for CLI interactions, open to open URLs in a browser.
  • Standard Pattern: Many CLI tools prompt the user to report the issue with pre-filled details on encountering an error. The approach of formatting the error and opening a GitHub issue URL is fairly standard.

Additional Considerations

  • User Consent: Always get user consent before opening the browser, as it can be intrusive.
  • Sensitive Information: Be cautious about including sensitive information in automated error reports.
  • Customization: Allow users to add additional comments or details before submitting the issue.

This approach aligns with standard practices and uses popular Node.js libraries for implementation. Remember to replace yourusername and yourrepo with your actual GitHub username and repository name in the URL.

@pionxzh
Copy link
Owner

pionxzh commented Jan 21, 2024

Let me finalize what we can do in this issue:

  • Automatically catch exceptions and create URLs where issues can be submitted
  • Implement a size checker before running. If the file size exceeds a limit, the tool give a hint that guides users on how to configure the memory limit to prevent OOM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request scope: cli
Projects
None yet
Development

No branches or pull requests

3 participants