Coder Social home page Coder Social logo

add easy-to-use CLI features about wakaru HOT 7 OPEN

StringKe avatar StringKe commented on May 28, 2024
add easy-to-use CLI features

from wakaru.

Comments (7)

pionxzh avatar pionxzh commented on May 28, 2024 1

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.

from wakaru.

pionxzh avatar pionxzh commented on May 28, 2024 1

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.

from wakaru.

pionxzh avatar pionxzh commented on May 28, 2024 1

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.

from wakaru.

pionxzh avatar pionxzh commented on May 28, 2024

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 πŸ€”

from wakaru.

StringKe avatar StringKe commented on May 28, 2024

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).

from wakaru.

0xdevalias avatar 0xdevalias commented on May 28, 2024

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:

from wakaru.

0xdevalias avatar 0xdevalias commented on May 28, 2024

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.

from wakaru.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.