Convert Figma logo to code with AI

gleitz logohowdoi

instant coding answers via the command line

10,557
867
10,557
26

Top Related Projects

Browse Hacker News like a haxor: A Hacker News command line interface (CLI).

38,110

the only cheat sheet you need

50,319

📚 Collaborative cheatsheets for console commands

6,086

:mag: Google from the terminal

A very fast implementation of tldr in Rust.

🖥 📊 🕹 🛠 A curated list of command line apps

Quick Overview

Howdoi is a command-line tool that provides instant coding answers from the web. It allows developers to quickly find solutions to programming questions without leaving the terminal, by scraping and presenting relevant code snippets from websites like Stack Overflow.

Pros

  • Saves time by providing quick access to coding solutions
  • Works directly from the command line, maintaining developer workflow
  • Supports a wide range of programming languages and topics
  • Customizable with various options for output formatting and source selection

Cons

  • May not always provide the most up-to-date or accurate information
  • Relies on the quality of answers available on Stack Overflow and similar sites
  • Can sometimes return irrelevant results for complex or ambiguous queries
  • Requires an internet connection to function

Code Examples

  1. Basic usage:
howdoi reverse a list in python

This command will return a code snippet showing how to reverse a list in Python.

  1. Specifying the number of answers:
howdoi -n 3 create a REST API in Node.js

This command will return three different code snippets or explanations for creating a REST API in Node.js.

  1. Getting a full answer page:
howdoi -a convert json to csv in python

This command will return the full answer page for converting JSON to CSV in Python, including any explanations and multiple code snippets if available.

Getting Started

To install howdoi, use pip:

pip install howdoi

Once installed, you can start using howdoi immediately by typing queries in your terminal:

howdoi [your programming question here]

For more options and customization, you can use various flags:

howdoi -c -n 3 [your question]  # Returns colorized output with 3 answers
howdoi -e [your question]       # Opens the answer link in your browser
howdoi -l [your question]       # Displays only the code from the answer

Refer to the project's README for a full list of available options and advanced usage instructions.

Competitor Comparisons

Browse Hacker News like a haxor: A Hacker News command line interface (CLI).

Pros of haxor-news

  • Provides a command-line interface for browsing Hacker News, offering a more immersive experience
  • Includes features like filtering, sorting, and viewing comments directly in the terminal
  • Supports user authentication for voting and commenting on Hacker News

Cons of haxor-news

  • More complex setup and usage compared to the simplicity of howdoi
  • Limited to Hacker News content, while howdoi can search across multiple sources
  • Requires more system resources due to its broader feature set

Code comparison

haxor-news:

def print_items(self, items):
    for item in items:
        self._print_item(item)

howdoi:

def get_answer(query, num_answers):
    links = get_links(query)
    answers = []
    for link in links[:num_answers]:
        answers.append(get_answer_from_link(link))
    return answers

The code snippets show that haxor-news focuses on displaying items from Hacker News, while howdoi is designed to fetch and present answers to programming questions from various sources. This reflects the different purposes of the two projects: haxor-news as a Hacker News client and howdoi as a quick reference tool for developers.

38,110

the only cheat sheet you need

Pros of cheat.sh

  • Broader coverage of topics, including programming languages, tools, and general commands
  • Supports multiple interfaces: command-line, web, and API
  • Allows community contributions and updates

Cons of cheat.sh

  • May provide more complex or verbose answers
  • Requires an internet connection for all queries

Code Comparison

howdoi:

def get_answer(query):
    return google_answer(query) or stackoverflow_answer(query)

cheat.sh:

def get_answer(query):
    return (
        cache.get(query) or
        community_contrib(query) or
        stackoverflow_answer(query) or
        documentation_lookup(query)
    )

Both projects aim to provide quick answers to programming questions, but they differ in their approach and scope. howdoi focuses on extracting answers from Stack Overflow, while cheat.sh offers a more comprehensive knowledge base with multiple sources and interfaces.

howdoi is simpler to use and install, making it ideal for quick, specific queries. cheat.sh, on the other hand, provides more extensive information and supports a wider range of topics, but may require more setup and interpretation of results.

Ultimately, the choice between the two depends on the user's needs: howdoi for straightforward coding questions, and cheat.sh for broader technical information and more detailed explanations.

50,319

📚 Collaborative cheatsheets for console commands

Pros of tldr

  • Larger community-driven database of commands and examples
  • Available offline and in multiple languages
  • Easier to contribute and maintain due to simple markdown format

Cons of tldr

  • Limited to command-line tools and common tasks
  • Less dynamic, doesn't provide real-time answers to specific questions
  • Requires manual updates to stay current

Code comparison

tldr (example page content):

# ls

List directory contents.

- List files one per line:
  ls -1

- List all files, including hidden files:
  ls -a

- List all files, with trailing / added to directory names:
  ls -F

howdoi (example usage):

from howdoi import howdoi

query = "reverse a string in python"
answer = howdoi.howdoi(query)
print(answer)

Summary

tldr focuses on providing concise, community-curated command-line examples for various tools and tasks. It offers a wide range of commands across multiple platforms and languages. howdoi, on the other hand, is a dynamic tool that fetches answers to programming questions from the internet in real-time. While tldr is more comprehensive for command-line tasks, howdoi is more flexible for general programming queries.

6,086

:mag: Google from the terminal

Pros of googler

  • Offers more comprehensive search capabilities, including news and image search
  • Provides a terminal-based interface for Google search, maintaining privacy
  • Supports multiple output formats (JSON, CSV) for easy integration with other tools

Cons of googler

  • Focused solely on Google search, while howdoi is specifically for programming questions
  • May require more setup and configuration compared to howdoi's simpler approach
  • Less targeted towards quick coding answers, which is howdoi's primary purpose

Code comparison

howdoi:

def get_answer(query):
    url = get_google_url(query)
    result = requests.get(url).text
    links = get_links(result)
    return get_answer_from_links(links)

googler:

def google_search(query, num_results):
    url = build_google_url(query, num_results)
    response = requests.get(url, headers=HEADERS)
    return parse_results(response.text)

Both projects use similar approaches for querying Google and parsing results, but googler offers more flexibility in search options and result handling.

A very fast implementation of tldr in Rust.

Pros of tealdeer

  • Written in Rust, offering better performance and memory safety
  • Supports offline caching of pages for faster access
  • Allows customization of color schemes and page rendering

Cons of tealdeer

  • Limited to command-line usage, lacking web interface or IDE integration
  • Smaller community and fewer contributors compared to howdoi

Code Comparison

tealdeer:

let config = Config::load()?;
let cache = Cache::new(config.cache_dir())?;
let page = cache.get_page(&query)?;
println!("{}", page.render(&config));

howdoi:

def get_answer(args, position):
    links = get_links(args['query'])
    link = get_link_at_pos(links, position)
    page = get_text(link)
    answer = get_answer_from_page(page)
    return answer

Summary

tealdeer focuses on providing fast, offline access to command-line cheatsheets, while howdoi aims to answer programming questions from various online sources. tealdeer offers better performance and customization options, but howdoi provides a broader range of information sources and integration possibilities.

🖥 📊 🕹 🛠 A curated list of command line apps

Pros of awesome-cli-apps

  • Comprehensive collection of CLI apps across various categories
  • Regularly updated with new additions and community contributions
  • Serves as a valuable resource for discovering new CLI tools

Cons of awesome-cli-apps

  • Not a standalone tool, but rather a curated list of other tools
  • Requires manual exploration to find specific solutions
  • May include outdated or less maintained projects

Code comparison

Not applicable, as awesome-cli-apps is a curated list and doesn't contain executable code. howdoi, on the other hand, is a functional CLI tool. Here's a sample usage of howdoi:

$ howdoi format date bash
DATE=`date +%Y-%m-%d`
echo $DATE

Summary

awesome-cli-apps is a comprehensive resource for discovering CLI tools, while howdoi is a specific tool for getting quick answers to programming questions. awesome-cli-apps offers a broader scope but requires more manual exploration, whereas howdoi provides immediate, targeted assistance for coding queries. The choice between them depends on whether you're looking for a variety of CLI tools or seeking quick solutions to programming problems.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Sherlock, your neighborhood command-line sloth sleuth

howdoi

Instant coding answers via the command line

⚡ Never open your browser to look for help again ⚡

build status downloads Python versions


Introduction to howdoi

Are you a hack programmer? Do you find yourself constantly Googling for how to do basic programming tasks?

Suppose you want to know how to format a date in bash. Why open your browser and read through blogs (risking major distraction) when you can simply stay in the console and ask howdoi:

$ howdoi format date bash
> DATE=`date +%Y-%m-%d`

howdoi will answer all sorts of queries:

$ howdoi print stack trace python
> import traceback
>
> try:
>     1/0
> except:
>     print '>>> traceback <<<'
>     traceback.print_exc()
>     print '>>> end of traceback <<<'
> traceback.print_exc()

$ howdoi convert mp4 to animated gif
> video=/path/to/video.avi
> outdir=/path/to/output.gif
> mplayer "$video" \
>         -ao null \
>         -ss "00:01:00" \  # starting point
>         -endpos 10 \ # duration in second
>         -vo gif89a:fps=13:output=$outdir \
>         -vf scale=240:180

$ howdoi create tar archive
> tar -cf backup.tar --exclude "www/subf3" www

image

Installation

pip install howdoi

or

brew install howdoi

Usage

New to howdoi?

howdoi howdoi

RTFM

Commands

usage: howdoi [-h] [-p POS] [-n NUM] [-a] [-l] [-c] [-x] [-C] [-j] [-v] [-e [ENGINE]]
[--save] [--view] [--remove] [--empty] [QUERY ...]

instant coding answers via the command line

positional arguments:
  QUERY                 the question to answer

optional arguments:
  -h, --help            show this help message and exit
  -p POS, --pos POS     select answer in specified position (default: 1)
  -n NUM, --num NUM     number of answers to return (default: 1)
  -a, --all             display the full text of the answer
  -l, --link            display only the answer link
  -c, --color           enable colorized output
  -x, --explain         explain how answer was chosen
  -C, --clear-cache     clear the cache
  -j, --json            return answers in raw json format
  -v, --version         display the current version of howdoi
  -e [ENGINE], --engine [ENGINE]
                        search engine for this query (google, bing, duckduckgo)
  --save, --stash       stash a howdoi answer
  --view                view your stash
  --remove              remove an entry in your stash
  --empty               empty your stash

environment variable examples:
  HOWDOI_COLORIZE=1
  HOWDOI_DISABLE_CACHE=1
  HOWDOI_DISABLE_SSL=1
  HOWDOI_SEARCH_ENGINE=google
  HOWDOI_URL=serverfault.com

Using the howdoi stashing feature (for more advanced features view the keep documentation).

stashing: howdoi --save QUERY
viewing:  howdoi --view
removing: howdoi --remove (will be prompted which answer to delete)
emptying: howdoi --empty (empties entire stash, will be prompted to confirm)

As a shortcut, if you commonly use the same parameters each time and don't want to type them, add something similar to your .bash_profile (or otherwise). This example gives you 5 colored results each time.

alias h='function hdi(){ howdoi $* -c -n 5; }; hdi'

And then to run it from the command line simply type:

$ h format date bash

You can also search other StackExchange properties for answers:

HOWDOI_URL=cooking.stackexchange.com howdoi make pesto

or as an alias:

alias hcook='function hcook(){ HOWDOI_URL=cooking.stackexchange.com howdoi $* ; }; hcook'
hcook make pesto

Other useful aliases:

alias hless='function hdi(){ howdoi $* -c | less --raw-control-chars --quit-if-one-screen --no-init; }; hdi'

Integrations

Contributors

How to contribute

We welcome contributions that make howdoi better and improve the existing functionalities of the project. We have created a separate guide to contributing to howdoi that explains how to get up and running with your first pull request.

Notes

  • Works with Python 3.7 and newer. Unfortunately Python 2.7 support has been discontinued :(
  • Special thanks to Rich Jones (@miserlou) for the idea
  • More thanks to Ben Bronstein for the logo