# Technical Documentation: gleitz/howdoi

> ℹ️ **Provenance:** Multi-Tier Ingestion · [CodeWiki Reference](https://codewiki.google/github.com/gleitz/howdoi)

### Overview (`README.md`)

<p align="center">
    <a href="https://pypi.python.org/pypi/howdoi">
        <img src="https://www.dropbox.com/s/dk13iy2uoufdwr7/HowDoIcolor512.png?raw=1" alt="Sherlock, your neighborhood command-line sloth sleuth" />
    </a>
</p>
<h1 align="center">howdoi</h1>
<h2 align="center">Instant coding answers via the command line</h2>
<p align="center"><strong>⚡ Never open your browser to look for help again ⚡</strong></p>

<p align="center">
    <a href="https://github.com/gleitz/howdoi/actions?query=workflow%3A%22Python+CI%22"><img src="https://img.shields.io/github/actions/workflow/status/gleitz/howdoi/python.yml?style=plastic&color=78dce8" alt="build status"></a>
    <a href="https://pepy.tech/project/howdoi"><img src="https://img.shields.io/pypi/dm/howdoi?style=plastic&color=ab9df2&maxAge=86400&label=downloads&query=%24.total_downloads&url=https%3A%2F%2Fapi.pepy.tech%2Fapi%2Fprojects%2Fhowdoi" alt="downloads"></a>
    <a href="https://pypi.python.org/pypi/howdoi"><img src="https://img.shields.io/pypi/pyversions/howdoi.svg?style=plastic&color=ff6188" alt="Python versions"></a>
</p>

------------------------------------------------------------------------

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

[](https://xkcd.com/1168/)

## Installation

    pip install howdoi

or

    brew install howdoi

## Usage

### New to howdoi?

    howdoi howdoi

### RTFM

-   [Introduction and
    installation](http://gleitz.github.io/howdoi/introduction/)
-   [Usage](http://gleitz.github.io/howdoi/usage/)
-   [Contributing to
    howdoi](http://gleitz.github.io/howdoi/contributing_to_howdoi/)
-   [Advanced
    usage](http://gleitz.github.io/howdoi/howdoi_advanced_usage/)
-   [Troubleshooting](http://gleitz.github.io/howdoi/troubleshooting/)

### 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](https://github.com/OrkoHunter/keep)).

    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](https://stackexchange.com/sites#traffic) 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

-   Slack integration available through
    [slack-howdoi](https://github.com/ellisonleao/slack-howdoi)
-   Telegram integration available through
    [howdoi-telegram](https://github.com/aahnik/howdoi-telegram)
-   Discord integration available through
    [discord-howdoi](https://github.com/MLH-Fellowship/0.5.1-howDoIDiscord)
-   Emacs integration available through
    [emacs-howdoi](https://blog.gleitzman.com/post/700738401851277312/howdoi-use-howdoi-in-emacs)
-   VSCode integration available on the
    [marketplace](https://marketplace.visualstudio.com/items?itemName=howdoi-org.howdoi)
-   Alfred integration available through
    [alfred-howdoi](https://github.com/gleitz/alfred-howdoi)

## Contributors

-   Benjamin Gleitzman ([\@gleitz](http://twitter.com/gleitz))
-   Yanlam Ko ([\@YKo20010](https://github.com/YKo20010))
-   Diana Arreola ([\@diarreola](https://github.com/diarreola))
-   Eyitayo Ogunbiyi ([\@tayoogunbiyi](https://github.com/tayoogunbiyi))
-   Chris Nguyen ([\@chrisngyn](https://github.com/chrisngyn))
-   Shageldi Ovezov ([\@ovezovs](https://github.com/chrisngyn))
-   Mwiza Simbeye
    ([\@mwizasimbeye11](https://github.com/mwizasimbeye11))
-   Shantanu Verma ([\@SaurusXI](https://github.com/SaurusXI))
-   Sheza Munir ([\@ShezaMunir](https://github.com/ShezaMunir))
-   Jyoti Bisht ([\@joeyouss](https://github.com/joeyouss))
-   And [more!](https://github.com/gleitz/howdoi/graphs/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](http://gleitz.github.io/howdoi/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](https://github.com/miserlou)) for the idea
-   More thanks to [Ben Bronstein](https://benbronstein.com/) for the
    logo

---

### Overview (`extension/code-editor-integration/README.md`)

# Code Editor Integration Development


Simplifies the process of integrating howdoi as a code editor extension.

## Description

The Code Editor Integration plug-in is ran by calling the `runHowdoi` function which takes in a user's query of type string. The parameter is encapsulated by a single line comment and is formatted as follows:

    // howdoi query

`runHowdoi` returns an Object with the structure:

    {
        question: string
        answer: string[]
        link: string[] 
    }

The Object values:
* question contains the user's query encapsulated by a single line comment
* answer contains the three possible answers to the user's query 
* link contains the three possible links to the answer encapsulated by a single line comment


## Installation

First, install howdoi on your machine.

Then, install all necessary packages:

    npm install

## Development

To compile the script:

    npm run compile

To run the script:

    npm start

To compile and run the script:

    npm run build

To run the testing script:

    npm test

## Integration

To utilize this plug-in to create a howdoi extension for a code editor: 

1. Copy the `code-editor-integration` folder into your workspace and remove the `node_modules` folder by adding the script
    
        "copy": "ncp ../code-editor-integration/ src/code-editor-integration/"
        "clean": "rimraf ./src/code-editor-integration/node_modules"
  
    into your `package.json` file and running it.
    First, you will need to install [ncp](https://www.npmjs.com/package/ncp) and [rimraf](https://www.npmjs.com/package/rimraf).

2. Import the `plugin.ts` file into your main file.
    
3. Call the `runHowdoi` function.

Refer to `vscode-howdoi` for an example.

## Usage

usage: 
    
    // howdoi query [-n NUM_ANSWERS]

positional arguments:

      QUERY                 the question to answer

optional arguments:

      -n NUM_ANSWERS        NUM_ANSWERS
                            number of answers to return
                            (default: 3)

---

### Overview (`extension/vscode-howdoi/README.md`)

# 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 code editor and ask [howdoi](https://github.com/gleitz/howdoi#howdoi):




howdoi will answer all sorts of queries:



## Installation

Install howdoi on your machine before using the howdoi extension. To do so, refer to the [howdoi installation steps](https://github.com/gleitz/howdoi#installation).

## Getting Started

The howdoi extension allows users to ask howdoi within their own code editor. 

For usage within the code editor:

1. Write down your question in the code editor commented out with a single line comment. 

    

2. Highlight the text from the first step.

    

3. Open the command palette using:

        cmd/ctrl + shift + P
    or
    
        View > Command Palette

4. Run howdoi in command palette and choose among three answers from the drop down.

    

## Usage

usage: 
    
    // howdoi query [-n NUM_ANSWERS]

positional arguments:

      QUERY                 the question to answer

optional arguments:

      -n NUM_ANSWERS        NUM_ANSWERS
                            number of answers to return
                            (default: 3)

example:

      


## Release Notes


### 1.0.0

Initial release of the howdoi VS Code Extension.


-----------------------------------------------------------------------------------------------------------

**Enjoy!**

---

### Overview (`extension/vscode-pkg/README.md`)

# howdoi Packaged Visual Studio Code Extension

Locally install the howdoi Visual Studio Code Extension.

## Installation

- Head over [here](https://github.com/gleitz/howdoi#installation) to install howdoi on your machine.

- Open Visual Studio Code and open the Command Palette and run:

        Shell Command: Install ‘code’ command in PATH
    
    
    Restart your terminal.
- Within the `extension/vscode-pkg` folder, run:

        code --install-extension howdoi-0.0.1.vsix

- Add the unpackaged files to your VS Code extensions folder (the path of the folder can be found [here](https://code.visualstudio.com/api/working-with-extensions/publishing-extension#your-extension-folder)). If no files were created within the `extension/vscode-pkg`, check if the files are in the extension folder path.

- Look over the README within the unpackaged files for more info on how to run howdoi within VS Code.

---

### Index (`docs/index.md`)

# howdoi
Never open your browser to look for help again.

Create tar archive:
```bash
$ howdoi create tar archive
> tar -cf backup.tar --exclude "www/subf3" www
```

Format a date in bash:
```bash
$ howdoi format date bash
> DATE=`date +%Y-%m-%d`
```
Print stack trace in Python:
``` bash
$ howdoi print stack trace python
> import traceback
>
> try:
>     1/0
> except:
>     print '>>> traceback <<<'
>     traceback.print_exc()
>     print '>>> end of traceback <<<'
> traceback.print_exc()
```

Convert MP4 to GIF:
```bash
$ 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
```

---

### Contributing (`docs/contributing.md`)

## General guidelines

Be sure to go through these items before creating a new issue:

1. Check the [existing issues](https://github.com/gleitz/howdoi/issues) to see if anyone is already working or have already worken on your issue or a similar one.

2. If there are no current or past issues similar to yours, be sure to give a a **complete description** when creating it.

3. Wait for feedback on the issue before starting to work.

!!! tip
    Include instructions on how to reproduce the bug you found or specific use cases of a requested feature.

!!! Note
    Follow Github's [guide to collaborating efficiently](https://lab.github.com/githubtraining/introduction-to-github).



## Setting up development environment

Clone the git repository
```bash
$ git clone https://github.com/gleitz/howdoi.git
```

Setup and activate a virtual environment
```bash
$ python3 -m venv .venv
$ source .venv/bin/activate
```

Install packages
```bash
$ pip install -r requirements.txt
```

## Running howdoi

Run on the command-line
```bash
python -m howdoi QUERY
```

!!! note
    If you try running `python howdoi/howdoi.py` (without `-m`) you might get `ValueError: Attempted relative import in non-package`.

If you want to use howdoi from within a python script, just pass your query to `howdoi.howdoi()`

```python
from howdoi import howdoi

query = "for loop python"
output = howdoi.howdoi(query)
```

Or parse it yourself and passed the arguments to `howdoi.howdoi()`
```python
from howdoi import howdoi

query = "for loop python"
parser = howdoi.get_parser()
args = vars(parser.parse_args(query.split(' ')))

output = howdoi.howdoi(args)
```

!!! attention
    Parsing queries yourself is the older way to pass in queries and may be deprecated in the future. Prefer the first example.


## Submitting Pull Requests
Before PRs are accepted they must pass all [Travis tests](https://travis-ci.org/gleitz/howdoi) and not have any `flake8` or `pylint` warnings or errors.

#### Testing
Howdoi uses python's [`unittest`](https://docs.python.org/3/library/unittest.html) library for unit testing. Run the unit tests locally

```bash
$ python -m test_howdoi
```

It's also possible to run only specific tests

```bash
$ python -m unittest test_howdoi.TestClass.test_method
```

Make sure all tests pass before submitting a PR.

!!! tip
    Remmember to run the tests while inside the virtual environment (run `source .venv/bin/activate` to activate it).

#### Linting
Run linting locally with [`flake8`](https://flake8.pycqa.org/en/latest/)
```bash
$ flake8
```
Or [`pylint`](https://www.pylint.org/)
```bash
$ pylint *
```

!!! tip
    Howdoi uses vanilla configuration files for both linters (`.flake8rc` and `.pylintrc` in the root directory), but with a max line length of 119 characters.


## Documentation

To get started building the docs first download `mkdocs`

```bash
$ pip install mkdocs-material markdown-include
```

#### Commands

* `python -m mkdocs new [dir-name]` - Create a new project.
* `python -m mkdocs serve` - Start the live-reloading docs server.
* `python -m mkdocs build` - Build the documentation site.
* `python -m mkdocs help` - Print this help message.


#### Project layout

    mkdocs.yml    # The configuration file.
    docs/
        index.md  # The documentation homepage.
        ...       # Other markdown pages, images and other files.


#### Here are some example alerts you can use
These are from the [Adomonition](https://python-markdown.github.io/extensions/admonition/) extension

!!! attention
    attention alert

!!! caution
    caution alert

!!! warning
    warning alert

!!! danger
    danger alert

!!! error
    error alert

!!! hint
    hint alert

!!! important
    important alert

!!! tip
    tip alert

!!! note
    note alert

!!! Custom alert
    Custom alert

Alternatively you can use the `!!! type "Custom Title"` format to get the correct type emoji and use any title you want like so:

!!! tip "Tip type alert but with a custom title"
    they're good aren't they

#### Include source code in 1 line of code

To import code we can use this syntax inside of a code block with the language label:  "{\!path/to/file\!}".

Here's `../howdoi/__init__.py`

```Python
{!../howdoi/__init__.py!}
```

#### Here is a choice tab
Proper syntax highlighted code blocks in these don't work the way you'd think and I don't know how to get them to work normally without some extension

=== "Python"
    To do x in python use this code:

    ```python
    def main():
        print("Hello world")
    if __name__ == "__main__":
        main()
    ```

=== "Golang"
    To do x in golang use this code:

    ```go
    package main
    import "fmt"
    func main() {
        fmt.Println("Hello world")
    }
    ```


You can include the contents of a file
```Python
{!../howdoi/__init__.py!}
```

---

### Contributing Docs (`docs/contributing_docs.md`)

If you would like to improve the existing documentation, you can do so by using `mkdocs`. Howdoi uses mkdocs to render its documentation. Steps to contribute to docs:

- Every step from [Contributing to howdoi](http://gleitz.github.io/howdoi/contributing_to_howdoi/) remains the same with additional requirements of installing and building mkdocs.
- First, install mkdocs by running the following command:
  ```
  pip install mkdocs
  ```
- You can learn about mkdocs usage from [mkdocs documentation](https://www.mkdocs.org/user-guide/).
- You can propose your documentation by [creating a new issue](https://github.com/gleitz/howdoi/issues/new/choose).
- Once approved in the issue, you can create a PR with modifications to the mkdocs markdown.
- Next, create a new branch and go to the folder `howdoi/docs/` and add a .md file.
- Go to `mkdocs.yml` and add the name of your added .md file in `nav`
- To see the changes in your local server, go to your terminal and in this directory run :

```
   $ mkdocs build
   $ mkdocs serve
```

- Once done, make a PR for the same and wait for it to be reviewed.

---

### Contributing To Howdoi (`docs/contributing_to_howdoi.md`)

As beginners, navigating the codebase and finding your way out of the documentation can become difficult. This page will help you understand everything about contributing to howdoi and the best practices in open source as well.
You can either contribute code to Howdoi (explained on this page) or contribute documentation (explained on next page)

#### Setting up the development environment

Follow the page [Setting up the development environment](http://gleitz.github.io/howdoi/development_env/) for setting up the development environment for Howdoi.

#### Finding your first issue

- Go to issues in the [howdoi repo](https://github.com/gleitz/howdoi).
- Find the issues which you might be interested to work on. Or, you can also come up with your own ideas of improving howdoi.
- After finding the issue you are interested in : If the issue is an existing one, comment on the issue and ask for it to be assigned to you. Or, if the issue is unlisted and new , create a new issue and fill every information needed in the issues template provided by howdoi and ask for it to be assigned to you.

- After receiving confirmation, start working on the issue and whenever and wherever help is needed, comment on the issue itself describing your query in detail.
- A good guide on how to collaborate efficiently can be found [here](https://lab.github.com/githubtraining/introduction-to-github){:target="\_blank"}.

#### Making a Pull request (PR)

- After you have worked on the issue and fixed it, we need to merge it from your forked repository into the howdoi repository. This is done by making a PR.
- You can search
  ```
  howdoi create a pull request on Github
  ```
  in your command line and follow the steps written in it.
- Each PR made should pass all the tests and should not have any flake8 or pylint errors. Github runs tests on each PR but we before that, you should run `python setup.py lint` which will run pylint and flake8.

- Once your commit passes all the tests, make a PR and wait for it to be reviewed and merged.

#### Asking for help

At times, help is needed while solving the issue. We recommend the following step for asking for help when you get stuck:

1. Read from howdoi docs and howdoi github to see if your answer has already been answered.
2. Comment on the issue you are working describing in detail what problems you are facing.
3. Make sure to write your query in detail and if it is bug, include steps to reproduce it.
4. If you are not working on any issue and have a question to be answered, open a new issue on Github and wait for a reply on it.

---

### Development Env (`docs/development_env.md`)

- Clone the howdoi repository:

  ```
  $ git clone https://github.com/gleitz/howdoi.git
  ```

- To see how to set up the development for Windows, see [here](http://gleitz.github.io/howdoi/windows-contributing/).

- Set up and activate a virtual environment:

  ```
  $ python3 -m venv .venv
  $ source .venv/bin/activate
  ```

- Install all the required packages:

  ```
  $ pip install -r requirements/dev.txt
  ```

- Running from command line :

  ```
  $ python -m howdoi QUERY
  ```

- From a Python script, you can call howdoi with `howdoi.howdoi` and pass your query in the argument.

```
from howdoi import howdoi
query = "for loop python"
output = howdoi.howdoi(query)
```

Or, parse it yourself and then pass the arguments:

```
from howdoi import howdoi
query = "for loop python"
parser = howdoi.get_parser()
args = vars(parser.parse_args(query.split(' ')))
output = howdoi.howdoi(args)
```

#### Notes

- Parsing queries yourself is the older way to pass in queries and may be deprecated in the future. Please use the first example.
- If you try running `python howdoi/howdoi.py` (without -m) you might get `ValueError: Attempted relative import in non-package`.

---

### Extension Dev (`docs/extension_dev.md`)

## Extension development

You can integrate howdoi as a code editor extension. For this, you need to edit the files within the [extension/code-editor-integration](https://github.com/gleitz/howdoi/tree/master/extension/code-editor-integration) folder.
To improve the Visual Studio Code howdoi extension, edit the files within the [extension/vscode-howdoi](https://github.com/gleitz/howdoi/tree/master/extension/vscode-howdoi) folder and republish the extension.

#### How to integrate howdoi as a code editor extension?

1. The Code Editor Integration plug-in runs when you call
   ` runHowdoi` function which takes in a user’s query(type = string). The parameter is encapsulated by a single line comment and is formatted as : `// howdoi query`

   `runHowdoi` function returns and Object which looks like :

```
{
   Question: string
   Answer : string[]
   Link : string[]
}
```

2. What are these object values?

- question : it contains the user’s query encapsulated by a single line comment
- answer : contains the three possible answers to the user’s query.
- link : link contains the three possible links to the answer encapsulated by a single line comment

3. To start with development, you need to first install howdoi on your machine. Steps to do that lie here.

#### Development

Next, install all important packages by running `npm install`

- To compile the script, run `npm run compile`
- To run the script , run `npm start`
- To compile and run the script, run `npm run build`
- To run the testing script, run `npm test`
- Now, to utilize the plug-in to create a howdoi extension, you need to do the following

#### Integration

To use the plug-in to create a howdoi extension, follow these steps:

- Copy the `code-editor-integration` folder in your workspace and remove `node-modules` folder. You can do this by adding the script in your `package.json` file and running it. But, first you will need to install ncp and rimraf.:

```
"copy": "ncp ../code-editor-integration/ src/code-editor-integration/"
"clean": "rimraf ./src/code-editor-integration/node_modules"
```

- Import the `plugin.ts` file into your main file.
- Call the `runHowdoi` function.

#### Visual Code Extension development

To begin the development for Visual Studio Code extension, install all the necessary packages:

`npm install`

Then precompile the extension :

`npm run precompile`

To run and test extension, utilize the Visual Studio Code’s debugging tools.

---

### Howdoi Advanced Usage (`docs/howdoi_advanced_usage.md`)

- **Howdoi stashing feature** - We agree that sometimes you need to need search results for later and running the same query again and again
  won’t be that feasible. Hence, Howdoi has a stashing feature which allows you to save your query, view the query, delete the saved
  results and even empty the entire stash ! (see keep documentation for more information on stashing). Here is how you can do this:

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

- **Shortcuts for your parameters** - You might run the same parameters many times and again, typing them isn’t always the best option. You can use shortcuts for your parameters by using something like:

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

  And the in your command line, replace your parameters with your alias i.e. h:

  ```
  $ h format date bash
  ```

- **Other uses and aliases** - You can also search other StackExchange properties for answers.

  Example:

  ```
  $ HOWDOI_URL=cooking.stackexchange.com
  $ howdoi make pesto
  ```

  Or use an alias for the same :

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

- **Setting up environment variables** - Howdoi uses some environment variables which can be configured by the user as per his/her choice.
  The following are the environment variables and their usage :

  - HOWDOI_COLORIZE=1 - Colorizes the output produced.
  - HOWDOI_DISABLE_CACHE=1 - Disables the Caching functionality.
    Howdoi uses a cache for faster access to previous questions. The
    cache is stored in ~/.cache/howdoi.
  - HOWDOI_DISABLE_SSL=1 - Disables the SSL certificate.
  - HOWDOI_SEARCH_ENGINE=google - Changes the search engine to your
    preference (default: google, also supported: bing, duckduckgo).
    The -e flag will switch the underlying engine for a single query.
  - HOWDOI_URL=serverfault.com - Changes the source url for answers
    (default: stackoverflow.com, also supported: serverfault.com,
    pt.stackoverflow.com, full list).

---

### Introduction (`docs/introduction.md`)

Howdoi is an open source command line tool that gives answers to your questions right on the command line. Howdoi can be used by anyone and everyone who finds themselves Googling for answers to their basic programming questions.

You wonder:

```
howdoi print hello in python
```

We answer:

```
print(“hello”)
```

### Installation

You'll need:

- `pip`
- Python 3.7 or above. Python 2.7 support is discontinued.

To install howdoi:

`pip install howdoi`

Or

`pip install git+https://github.com/gleitz/howdoi.git#egg=howdoi`

> Don't have pip installed yet? [Follow this simple tutorial to get started](https://pip.pypa.io/en/stable/installing/)

If you want to use [setuptools]() to install howdoi you can do so like this:

`python setup.py install`

---

### Troubleshooting (`docs/troubleshooting.md`)

You might get the following error when installing with Homebrew:

```bash
==> python setup.py install

http://peak.telecommunity.com/EasyInstall.html

Please make the appropriate changes for your system and try again.
```

Fix the error by executing the following command:
```bash
sudo chmod -R go+w /Library/Python/2.7/site-packages/
```

An official lxml for python 3.3+ for windows has not yet been released. You may get an error while installing.
Try and install an [unofficial binary for lxml](http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml).

---

### Usage (`docs/usage.md`)

Let's start at the beginning.

```
$ howdoi howdoi
```

For further information about flags and environment variables:

```
$ howdoi -h
```

#### Howdoi Flags and Arguments

```
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
```

---

### Windows Contributing (`docs/windows-contributing.md`)

## Setting up a Windows Development environment 

 

Howdoi can be used on Windows, MacOS and Linux etc. But the development environment can only be set up in a Linux or Mac. To set up the development environment in Windows, follow the following steps: 

### Install WSL

WSL is Windows Subsystem for Linux. It offers Linux interoperability in Windows and allows users to set up a virtual environment. 

If you do not have WSL set up, follow the steps in this [tutorial](https://www.windowscentral.com/install-windows-subsystem-linux-windows-10) 

### Setting up the virtual environment

After setting up WSL, go to the directory where you want to set up Howdoi. Open the Command Prompt here and enter the following to enter the WSL environment. 

``` bash
bash 
``` 

Now you are using the Linux-compatible kernel on Windows and can set up a virtual environment. 

### Clone the git repository

```bash
$ git clone https://github.com/gleitz/howdoi.git 
``` 

Setup and activate a virtual environment: 

``` bash
$ python3 -m venv .venv 
$ source .venv/bin/activate 
``` 

Make sure you have pip installed, if not, enter: 

``` bash
$ sudo apt install python3-pip 
``` 

Go to the project directory and install requirements: 

``` bash
$ cd howdoi 
$ pip install -r requirements.txt 
``` 

> if howdoi does not process queries after this command, make sure your PATH variables for Python and Pip are set correctly in Windows environment variables.  

### Test run

Check to see if everything has been set-up correctly: 

```  bash
pip install howdoi 
howdoi  print hello world
```

---

--- METRICS ---
- Files Extracted: 15
- Estimated Token Budget: ~8079 tokens
- Canonical Reference: https://codewiki.google/github.com/gleitz/howdoi
