{"id":13502980,"url":"https://github.com/WindSoilder/hors","last_synced_at":"2025-03-29T13:30:32.958Z","repository":{"id":34873983,"uuid":"179772617","full_name":"WindSoilder/hors","owner":"WindSoilder","description":"instant coding answers via the command line (howdoi in rust)","archived":false,"fork":false,"pushed_at":"2024-04-05T15:56:46.000Z","size":3441,"stargazers_count":239,"open_issues_count":8,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-14T00:11:57.113Z","etag":null,"topics":["cli-tools","client","http"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WindSoilder.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-06T00:39:34.000Z","updated_at":"2024-09-20T16:45:10.000Z","dependencies_parsed_at":"2024-01-07T01:18:31.240Z","dependency_job_id":"d1395476-150f-42f9-975a-c46d417bba8c","html_url":"https://github.com/WindSoilder/hors","commit_stats":{"total_commits":386,"total_committers":8,"mean_commits":48.25,"dds":"0.15803108808290156","last_synced_commit":"f956f6baa0bd175b61ce8809849b2e62d5ad6d65"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WindSoilder%2Fhors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WindSoilder%2Fhors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WindSoilder%2Fhors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WindSoilder%2Fhors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WindSoilder","download_url":"https://codeload.github.com/WindSoilder/hors/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245978274,"owners_count":20703677,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli-tools","client","http"],"created_at":"2024-07-31T22:02:32.510Z","updated_at":"2025-03-29T13:30:32.935Z","avatar_url":"https://github.com/WindSoilder.png","language":"Rust","funding_links":[],"categories":["Rust","Applications","应用","\u003ca name=\"programming\"\u003e\u003c/a\u003eProgramming","Other"],"sub_categories":["Development","开发"],"readme":"[![Crate](https://img.shields.io/crates/v/hors.svg)](https://crates.io/crates/hors)\n[![CI](https://github.com/WindSoilder/hors/workflows/CI/badge.svg)](https://github.com/WindSoilder/hors/actions?query=workflow%3ACI)\n\n\n# [hors](https://crates.io/crates/hors)\nAwesome program [howdoi](https://github.com/gleitz/howdoi) which implemented in rust, along with easily usage lib.\n\nIt's faster than the original howdoi program.\n\nFor binary usage, please go through the rest of this file.  For lib documentation, please check [here](https://docs.rs/hors/latest/hors/).\n\n# Screenshot\n## Simple usage example\n![Screenshots of hors gif](screenshots/hors_demo.gif)\n\n## More examples\n\n![Screenshots of hors png](screenshots/screenshot.png)\n\n# Installation\nhors is written in `Rust`.  The recommended way to install `hors` is through `cargo`.\n\n```shell\ncargo install hors\n```\n\nOn Windows/Linux/macOS platform, you can download the pre-build-binary from github [release page](https://github.com/WindSoilder/hors/releases/latest)\n\n## On macOS\nHors can be installed from [homebrew](https://brew.sh/).\n\n```shell\nbrew tap hors-org/hors \u0026\u0026 brew install hors\n```\n\n## On Windows\nHors can be installed from [scoop](https://scoop.sh/)\n\n```shell\nscoop bucket add w-bucket https://github.com/hors-org/w-bucket; scoop install hors\n```\n\n# What make it fast\n1. Implemented in rust, which causes less runtime overhead.\n2. Make use of tokio concurrent feature, so hors will make concurrent search when it need to fetch more than 1 answer.\n3. Output will be cache, and when you want to search for the same question, hors will likely make less network traffic to get the answer.\n\nHere is a simple benchmark report, run the following command 3 times in my personal computer:\n```shell\ntime hors mysql create table with column comment -a -n 10 --paging never -e bing\nrm ~/Library/Caches/hors/answers\n```\nNote: run `rm` command is aimed to clear local cache.\n\nAnd it gives me the following output:\n\n```\nExecuted in    2.55 secs   fish           external\n   usr time  232.71 millis  150.00 micros  232.56 millis\n   sys time   16.68 millis  562.00 micros   16.12 millis\n\nExecuted in    3.68 secs   fish           external\n   usr time  252.02 millis  125.00 micros  251.90 millis\n   sys time   19.18 millis  550.00 micros   18.63 millis\n\nExecuted in    2.55 secs   fish           external\n   usr time  237.19 millis  117.00 micros  237.07 millis\n   sys time   17.63 millis  565.00 micros   17.06 millis\n```\n\nRun the same command with howdoi:\n```shell\ntime howdoi mysql create table with column comment -a -n 4 -e bing -c\nrm ~/Library/Caches/howdoi/*\n```\nNote: run `rm` command is aimed to clear howdoi local cache.\n\nAnd it gives me the following output:\n\n```\nExecuted in    3.48 secs   fish           external\n   usr time  303.67 millis  127.00 micros  303.54 millis\n   sys time   52.53 millis  601.00 micros   51.93 millis\n\nExecuted in    3.65 secs   fish           external\n   usr time  305.37 millis  111.00 micros  305.26 millis\n   sys time   53.16 millis  549.00 micros   52.61 millis\n\nExecuted in    3.34 secs   fish           external\n   usr time  319.07 millis   14.24 millis  304.83 millis\n   sys time   55.63 millis    3.37 millis   52.26 millis\n```\n\nBut please note that this simple benchmark is not precise, it highly depends on network information.\n\n# Tested platforms\nFor now, `hors` has been tested with the following platforms:\n\n- Linux\n- OSX\n- Windows\n\n# Usage\n```shell\nUSAGE:\n    hors [FLAGS] [OPTIONS] [query]...\n\nARGS:\n    \u003cquery\u003e...\n\nFLAGS:\n    -a, --all              display the full text of answer.\n        --clear-cache      just clear local hors cache.\n    -d, --disable-proxy    Disable system proxy.\n    -h, --help             Prints help information\n    -l, --link             display only the answer link.\n    -r, --raw              make raw output (not colorized).\n    -V, --version          Prints version information\n\nOPTIONS:\n    -e, --engine \u003cengine\u003e                    select middle search engine, currently support `bing`, `google`,\n                                             `duckduckgo`, `stackoverflow`. [env: HORS_ENGINE=bing]  [default:\n                                             duckduckgo]\n    -n, --number-answers \u003cnumber-answers\u003e    number of answers to return. [default: 1]\n    -p, --paging \u003cpaging\u003e                    specify how to page output, can be `auto`, `never` [default: auto]\n```\n\n# Usage example\n1.  Want to know how to export pandas dataframe to csv?\n```shell\nhors pandas dataframe to csv\n```\n\nHere it is:\n\n```\n- Answer from https://stackoverflow.com/questions/16923281/pandas-writing-dataframe-to-csv-file\ndf.to_csv(file_name, sep='\\t')\n```\n\n2. If we just want to know where is the answer existed?\n```shell\nhors pandas dataframe to csv -l\n```\n\nHere it is:\n```\nTitle - pandas writing dataframe to csv file\nhttps://stackoverflow.com/questions/16923281/pandas-writing-dataframe-to-csv-file\n```\n\n3. If we want more about the answer detailed?\n```shell\nhors how to parse json in rust -a\n```\n\nHere it is:\n```shell\n- Answer from https://stackoverflow.com/questions/30292752/how-do-i-parse-a-json-file\n\nSolved by the many helpful members of the Rust community:\n\nextern crate rustc_serialize;\nuse rustc_serialize::json::Json;\nuse std::fs::File;\nuse std::io::Read;\n\nfn main() {\n    let mut file = File::open(\"text.json\").unwrap();\n    let mut data = String::new();\n    file.read_to_string(\u0026mut data).unwrap();\n\n    let json = Json::from_str(\u0026data).unwrap();\n    println!(\"{}\", json.find_path(\u0026[\"Address\", \"Street\"]).unwrap());\n}\n```\n\n4. How to get more than one answers\n```shell\nhors set git remote url -n 2 -a\n```\nHere it is:\n```\n- Answer from https://stackoverflow.com/questions/2432764/how-to-change-the-uri-url-for-a-remote-git-repository\nYou can\n\ngit remote set-url origin new.git.url/here\n\n(see git help remote) or you can just edit .git/config and change the URLs there. You're not in any danger of losing history unless you do something very silly (and if you're worried, just make a copy of your repo, since your repo is your history.)\n\n\n^_^ ==================================================== ^_^\n\n- Answer from https://stackoverflow.com/questions/42830557/git-remote-add-origin-vs-remote-set-url-origin\nbelow is used to a add a new remote:\n\ngit remote add origin git@github.com:User/UserRepo.git\n\nbelow is used to change the url of an existing remote repository:\n\ngit remote set-url origin git@github.com:User/UserRepo.git\n\nbelow will push your code to the master branch of the remote repository defined with origin and -u let you point your current local branch to the remote master branch:\n\ngit push -u origin master\n\nDocumentation\n```\n\n5. The default search engine is bing, how can I use other search engine?\n```shell\nhors set git remote url -n 2 -a -e \"google\"\n```\n\n# Proxy support\nIf the network seems blocked, you can try to configure proxy like this:\n```shell\nexport http_proxy=http://127.0.0.1:1087;export https_proxy=http://127.0.0.1:1087;\n```\n\nOf course, it should be a valid proxy in your machine.\n\n# Paging feature on windows\nHors is using `less` command to make paging feature work, and it's not installed on Windows by default.  You can use scoop to install `less`\n\n```shell\nscoop install less\n```\n\nOr use `choco`:\n\n```shell\nchoco install less\n```\n\n\n# Use hors as lib\nHors can be used as a lib, here is an example:\n\n```rust\nuse std::str::FromStr;\nuse hors::{self, SearchEngine};\n\nlet search_engine: SearchEngine = SearchEngine::from_str(\"bing\").unwrap();\nlet target_links: Vec\u003cString\u003e = hors::search_links(\n    \"how to parse json in rust\",\n    search_engine,\n)\n.await\n.unwrap();\nassert_ne!(target_links.len(), 0);\nfor link in target_links {\n    assert!(link.contains(\"stackoverflow.com\"));\n}\n```\n\nFor more information, please check the [documentation](https://docs.rs/hors/latest/hors/)\n\n# Special thanks\nVery thanks for the awesome project and links :)\n- [howdoi](https://github.com/gleitz/howdoi) inspires `hors` (Fow now `hors` is `howdoi` which implements in `rust`).\n- [stackoverflow](https://stackoverflow.com/) helps users solve questions about coding.\n\n# About the name\n`hors` is the abbreviation of `howdoi in rust`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWindSoilder%2Fhors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FWindSoilder%2Fhors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWindSoilder%2Fhors/lists"}