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

feat: improved command-line to parser #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ Python 2.7 is already installed on most of the Linux distro.
1. Render the HTML on CLI using pandoc.
2. Get some source website to search for commands.

## Usage

- Search linux command
```shell
python main.py -s wikipedia -q pwd
```

### EXAMPLE
*Video and screenshot will be added soon.*

Expand Down
17 changes: 11 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
import requests
import argparse
from bs4 import BeautifulSoup
import os
import textwrap
import sys
import wikipedia
from GPT_API import *

sources = ['wikipedia', 'wiki', 'google', 'stackoverflow']

query = str(sys.argv[2])
site = str(sys.argv[1])
print("Want to know about the command : " + query)
print("Fetching information for the command "+query+" from "+site+".")
if(site == "wikipedia" or site == "wiki"):
parser = argparse.ArgumentParser()
parser.add_argument("-s", "--site", default="wikipedia", choices=sources)
parser.add_argument("-q", "--query", default="", required=True, help="command to search")

args = parser.parse_args()
print("Want to know about the command : " + args.query)
print("Fetching information for the command "+args.query+" from "+args.site+".")
if(args.site == "wikipedia" or args.site == "wiki"):

result = wikipedia.summary("'%s' linux command" %query, sentences = 7)
result = wikipedia.summary("'%s' linux command" %args.query, sentences = 7)
print(result)

# soup=BeautifulSoup(html_doc, 'html.parser')
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

bs4
requests
wikipedia
Expand Down