leetgo

command module
v0.1.0-alpha.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 3, 2023 License: MIT Imports: 1 Imported by: 0

README

Leetgo

Go Report Card CI PRs Welcome Twitter Follow

This project is still in its early development stage and many features have not yet been implemented. Everything is subject to rapid change.

中文 | English

leetgo is a command-line tool for LeetCode that provides almost all the functionality of LeetCode, allowing you to complete all of your LeetCode exercises without leaving the terminal. It can automatically generate skeleton code and test cases, support local testing and debugging, and you can use any IDE you like to solve problems.

And leetgo also supports real-time generation of contest questions, so your submissions are one step ahead!

asciicast

Highlight of features

  • Pick question with a simple and fancy UI.
  • Generate skeleton code and testing code for a question.
  • Run test cases on your local machine.
  • Generate contest questions just in time.
  • Support both leetcode.com and leetcode.cn

Language support

Currently, leetgo supports generating code and local test for the following languages:

Generate Local Test
Go
Python
C++
Rust
Java
JavaScript
PHP
C
C#
Ruby
Swift
Kotlin

and many other languages are in plan. (help wanted, contributions welcome!)

Installation

You can download the latest binary from the release page.

Install via go
go install github.com/j178/leetgo@latest
Install via brew
brew install j178/tap/leetgo
Install via scoop
scoop bucket add j178 https://github.com/j178/scoop-bucket.git
scoop install j178/leetgo

Usage

Usage:
  leetgo [command]

Available Commands:
  init                    Init a leetcode workspace
  pick                    Generate a new question
  info                    Show question info
  test                    Run question test cases
  submit                  Submit solution
  contest                 Generate contest questions
  cache                   Manage local questions cache
  config                  Show leetgo config dir
  encrypt                 Encrypt a sensitive string to be used in config file
  help                    Help about any command
  completion              Generate the autocompletion script for the specified shell

Flags:
  -v, --version       version for leetgo
  -l, --lang string   language of code to generate: cpp, go, python ...
  -y, --yes           answer yes to all prompts
  -h, --help          help for leetgo

Use "leetgo [command] --help" for more information about a command.

LeetCode Support

Leetgo uses LeetCode's GraphQL API to get questions and submit solutions. You need to provide your LeetCode session ID to authenticate.

Currently only leetcode.cn is supported. Support for leetcode.com is under development.

Configuration

Leetgo uses two levels of configuration files, the global configuration file located at ~/.config/leetgo/config.yaml and the local configuration file located at leetgo.yaml in the project root. These configuration files are generated during the leetgo init process. The local configuration file in the project will override the global configuration. It is generally recommended to use the global configuration as the default configuration and customize it in the project by modifying the leetgo.yaml file.

# Your name
author: Bob
# Language of code generated for questions: go, python, ... (will be override by project config and flag --lang)
lang: go
# Language of the question description: zh or en
language: zh
# LeetCode configuration
leetcode:
  # LeetCode site, https://leetcode.com or https://leetcode.cn
  site: https://leetcode.cn
  # Credential to access LeetCode
  credential:
    # Read leetcode cookie from browser, currently only chrome is supported.
    read_from_browser: chrome
contest:
  # Base dir to put generated contest questions
  out_dir: ""
# The editor to open generated files
editor:
  # The mark to indicate the beginning of the code
  code_begin_mark: '@lc code=start'
  # The mark to indicate the end of the code
  code_end_mark: '@lc code=end'
  command: vim
  args: []
# Cache type, json or sqlite
cache: json
go:
  out_dir: go
  # Generate separate package for each question
  separate_package: true
  # Filename template for Go files
  filename_template: ""
python:
  out_dir: python
cpp:
  out_dir: cpp
java:
  out_dir: java
rust:
  out_dir: rust
c:
  out_dir: c
csharp:
  out_dir: csharp
javascript:
  out_dir: javascript
ruby:
  out_dir: ruby
swift:
  out_dir: swift
kotlin:
  out_dir: kotlin
php:
  out_dir: php

Troubleshooting

If you encounter any problems, please run your command with DEBUG environment variable set to 1, copy the command output and open an issue.

Contributions welcome!

Good first issues are a great place to start, and you can also check out some help wanted issues.

Credits

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
testutils
go Module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL