windsoilder / hors Goto Github PK
View Code? Open in Web Editor NEWinstant coding answers via the command line (howdoi in rust)
License: GNU General Public License v3.0
instant coding answers via the command line (howdoi in rust)
License: GNU General Public License v3.0
Add function to clear cache as in howdoi.
I decided by adding to my .zshrc : alias hr=' rm -rf ~/.cache/hors/* &>/dev/null'
OS : Windows 10 using cmd.exe
and powershell
Upon trying your tool, it seems like the character encoding used to, I guess, color the lines, or at least add some text encoding, produces strange characters when used on Powershell and Windows CMD.
I suppose these are the special chracters used for the color formatting. I'm curious if it's possible, in the source code, to do automatic terminal detections to disable them when not on a compatible terminal.
And yes, I know about the -r
option, which I use, it's just that a Windows user not being aware of it might be surprised
hors "dart print text"
- Answer from https://stackoverflow.com/questions/21028751/how-do-i-print-to-the-console-with-dart
�[38;2;211;208;200mimport 'dart:html';
�[38;2;211;208;200m
�[38;2;211;208;200mmain() {
�[38;2;211;208;200m var value = querySelector('input').value;
�[38;2;211;208;200m print('The value of the input is: $value');
�[38;2;211;208;200m}
Refer to the comment
Packaging is a pain - first of all we need to package in the various formats and then we'll see how we make it to an official repo (debian/fedora/ubuntu/etc.). A milestone for a packaging action on every release should get in place
It's worth to investigate if there are any ways to auto-packaging on every release.
Just think that hors
should support proxy, so user don't need to care about system http proxy anymore.
And it's better to solve in the reqwest
module (here is the relative issue: seanmonstar/reqwest#403). So I can just upgrade reqwest
version without changing anycode.
Since hors currently accepts a single query argument, multi-word queries must be quoted.
A possible way to avoid requiring quoting, in the absence of special characters, would be to accept multiple arguments, and join them with spaces to form the query.
So running hors how do i rust
would result in the query how do i rust
.
A possible downside of doing this is that it wouldn't allow introducing additional positional arguments in the future. So, for example, it wouldn't be possible to introduce an optional positional argument for the engine, like horse 'how do i rust' bing
.
$ cargo install hors
...
Compiling hors v0.8.2
error[E0432]: unresolved import `clap::Clap`
--> /home/yonas/.cargo/registry/src/github.com-1ecc6299db9ec823/hors-0.8.2/src/bin/hors.rs:4:18
|
4 | use clap::{self, Clap};
| ^^^^ no `Clap` in the root
error: cannot determine resolution for the derive macro `Clap`
--> /home/yonas/.cargo/registry/src/github.com-1ecc6299db9ec823/hors-0.8.2/src/bin/hors.rs:12:10
|
12 | #[derive(Clap)]
| ^^^^
|
= note: import resolution is stuck, try simplifying macro imports
error: cannot find attribute `clap` in this scope
--> /home/yonas/.cargo/registry/src/github.com-1ecc6299db9ec823/hors-0.8.2/src/bin/hors.rs:13:3
|
13 | #[clap(version = env!("CARGO_PKG_VERSION"), author = env!("CARGO_PKG_AUTHORS"), about = env!("CARGO_PKG_DESCRIPTION"))]
| ^^^^
|
note: `clap` is imported here, but it is a crate, not an attribute
--> /home/yonas/.cargo/registry/src/github.com-1ecc6299db9ec823/hors-0.8.2/src/bin/hors.rs:4:12
|
4 | use clap::{self, Clap};
| ^^^^
error: cannot find attribute `clap` in this scope
--> /home/yonas/.cargo/registry/src/github.com-1ecc6299db9ec823/hors-0.8.2/src/bin/hors.rs:15:7
|
15 | #[clap(long, about("just clear local hors cache."))]
| ^^^^
|
note: `clap` is imported here, but it is a crate, not an attribute
--> /home/yonas/.cargo/registry/src/github.com-1ecc6299db9ec823/hors-0.8.2/src/bin/hors.rs:4:12
|
4 | use clap::{self, Clap};
| ^^^^
error: cannot find attribute `clap` in this scope
--> /home/yonas/.cargo/registry/src/github.com-1ecc6299db9ec823/hors-0.8.2/src/bin/hors.rs:17:7
|
17 | #[clap(short, long, about("display the full text of answer."))]
| ^^^^
|
note: `clap` is imported here, but it is a crate, not an attribute
--> /home/yonas/.cargo/registry/src/github.com-1ecc6299db9ec823/hors-0.8.2/src/bin/hors.rs:4:12
|
4 | use clap::{self, Clap};
| ^^^^
error: cannot find attribute `clap` in this scope
--> /home/yonas/.cargo/registry/src/github.com-1ecc6299db9ec823/hors-0.8.2/src/bin/hors.rs:19:7
|
19 | #[clap(short, long, about("display only the answer link."))]
| ^^^^
|
note: `clap` is imported here, but it is a crate, not an attribute
--> /home/yonas/.cargo/registry/src/github.com-1ecc6299db9ec823/hors-0.8.2/src/bin/hors.rs:4:12
|
4 | use clap::{self, Clap};
| ^^^^
error: cannot find attribute `clap` in this scope
--> /home/yonas/.cargo/registry/src/github.com-1ecc6299db9ec823/hors-0.8.2/src/bin/hors.rs:21:7
|
21 | #[clap(short, long, about("make raw output (not colorized)."))]
| ^^^^
|
note: `clap` is imported here, but it is a crate, not an attribute
--> /home/yonas/.cargo/registry/src/github.com-1ecc6299db9ec823/hors-0.8.2/src/bin/hors.rs:4:12
|
4 | use clap::{self, Clap};
| ^^^^
error: cannot find attribute `clap` in this scope
--> /home/yonas/.cargo/registry/src/github.com-1ecc6299db9ec823/hors-0.8.2/src/bin/hors.rs:23:7
|
23 | #[clap(
| ^^^^
|
note: `clap` is imported here, but it is a crate, not an attribute
--> /home/yonas/.cargo/registry/src/github.com-1ecc6299db9ec823/hors-0.8.2/src/bin/hors.rs:4:12
|
4 | use clap::{self, Clap};
| ^^^^
error: cannot find attribute `clap` in this scope
--> /home/yonas/.cargo/registry/src/github.com-1ecc6299db9ec823/hors-0.8.2/src/bin/hors.rs:30:7
|
30 | #[clap(
| ^^^^
|
note: `clap` is imported here, but it is a crate, not an attribute
--> /home/yonas/.cargo/registry/src/github.com-1ecc6299db9ec823/hors-0.8.2/src/bin/hors.rs:4:12
|
4 | use clap::{self, Clap};
| ^^^^
error: cannot find attribute `clap` in this scope
--> /home/yonas/.cargo/registry/src/github.com-1ecc6299db9ec823/hors-0.8.2/src/bin/hors.rs:37:7
|
37 | #[clap(
| ^^^^
|
note: `clap` is imported here, but it is a crate, not an attribute
--> /home/yonas/.cargo/registry/src/github.com-1ecc6299db9ec823/hors-0.8.2/src/bin/hors.rs:4:12
|
4 | use clap::{self, Clap};
| ^^^^
error: cannot find attribute `clap` in this scope
--> /home/yonas/.cargo/registry/src/github.com-1ecc6299db9ec823/hors-0.8.2/src/bin/hors.rs:45:7
|
45 | #[clap(short, long, about("Disable system proxy."))]
| ^^^^
|
note: `clap` is imported here, but it is a crate, not an attribute
--> /home/yonas/.cargo/registry/src/github.com-1ecc6299db9ec823/hors-0.8.2/src/bin/hors.rs:4:12
|
4 | use clap::{self, Clap};
| ^^^^
error[E0599]: no function or associated item named `parse` found for struct `Opts` in the current scope
--> /home/yonas/.cargo/registry/src/github.com-1ecc6299db9ec823/hors-0.8.2/src/bin/hors.rs:54:28
|
14 | struct Opts {
| ----------- function or associated item `parse` not found for this struct
...
54 | let opts: Opts = Opts::parse();
| ^^^^^ function or associated item not found in `Opts`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following traits define an item `parse`, perhaps you need to implement one of them:
candidate #1: `Parser`
candidate #2: `TypedValueParser`
candidate #3: `time::parsing::parsable::sealed::Sealed`
Some errors have detailed explanations: E0432, E0599.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `hors` due to 12 previous errors
error: failed to compile `hors v0.8.2`, intermediate artifacts can be found at `/tmp/cargo-installiaOlVo`
rustc 1.64.0 (a55dd71d5 2022-09-19)
cargo 1.64.0 (387270bc7 2022-09-16)
Ubuntu 22.10
Hi, you could setup a GitHub Workflow to automatically release new tags.
This would allow people to just download the binaries and not have to worry about compiling it themselves.
For reference:
Ripgrep's workflow: https://github.com/BurntSushi/ripgrep/blob/master/.github/workflows/release.yml
GitUI's workflow: https://github.com/extrawurst/gitui/blob/master/.github/workflows/cd.yml
Level 1: user input -> answer
(When use input the same query, hors
can make use of cache and return relative answer immediately)
NOTE: it's especially when user use zsh
or git bash
, which have 'reverse-i-search' feature, when user use it to search for historical hors
command, it's easy to catch the cache. So the relative answer can return quickly. This is what howdoi
does for now.
To make cache a little more clever, when we save query, we can remove any space and punction.
Level 2: page link -> stackoverflow answer (which is already implemented)
Refer to this CI build report: https://travis-ci.org/github/WindSoilder/howdoi/jobs/723446603
It seems that for the body of answer node, it may have class post-text
or js-post-body
.
For now the behavior is just using js-post-body
to detect answer node, which is not good enough.
I know that this question is kinda stupid, but why don't we use SO's search? Search accuracy is bad? @WindSoilder
Provide installation from homebrew(on mac), apt(on linux), maybe others(Chocolatey on windows)
It may cause that stackoverflow change it's front-end page
relative issue: xd009642/tarpaulin#190
When using the DuckDuckGo search engine, hors sometimes gives this error:
$ hors -e duckduckgo 'rust string to str'
Hors is running to error: Network(Error(Url(RelativeUrlWithoutBase)))
This is because DuckDuckGo sometimes returns redirect links instead of direct links in its search results.
I have a problem with default coloring scheme. It contains both white and dark gray colored words, so half of it is very hard to read with whitish background theme, while another half with dark background theme (see screenshot).
Hors version is 0.6.4, run under KDE, Yakuake, Sweet console theme.
I tried other themes and it was still problematic.
I found a question with multiple answers: https://stackoverflow.com/questions/45015/safely-turning-a-json-string-into-an-object
Here there are <pre><code>
both empty and with the lang-
class in the html document (before JS rendering).
The second answer (answer-3627901), does not have a lang class:
While an answer further down (answer-51907405) has it - but it's a snippet:
And the last answer (answer-59526105) has it but it's not a snippet:
This concludes it. I THINK that if in the answer you post you put the language in the code fence (like ```Rust...
) it gets the class by the server. If not the client JS guesses the syntax
I think the best way to go on syntax guessing is to check for the class and then do the tag-rating system.
Search stackoverflow link failed with 'DuckDuckGo' search engine, you can try another engine through
-eargument, or specify
$HORS_ENGINE env variable to another value
Search stackoverflow link failed with 'Google' search engine, you can try another engine through
-eargument, or specify
$HORS_ENGINE env variable to another value
Google does not work through a proxy either.
DuckDuckGo does not always work through a proxy.
Only Bing it works through and without a proxy.
For now I found that when the cache size > 1.1M, the program is going to crash. Should add cache clear logic
Refer to #102
I figured out when deleting the hors directory, it doesn't get created. If you create it by hand, then history is written.
It would be nice to fix it.
It seems that this is not expected behavior.
seems to fail pretty hard in my environment, any way to give you more good data?
dom@darthdom:~$ hors c# literal array
- Answer from https://stackoverflow.com/questions/4894120/what-does-for-mean
while(true)
dom@darthdom:~$ hors csharp literal array
Search for target link failed: Parse("Can\'t find search result...")
$> hors -V
hors 0.6.8
Relative report: https://travis-ci.org/WindSoilder/hors/jobs/542539892
Because windows system is in early stages, so there may be the issue lays in travis. But still need to install hors
in windows system manually, to make sure that it just happened in travis.
Meanwhile, should try to find out a way to build up azure-pipeline
系统:windows 10
版本:hors 0.3.3
问题描述:在测试例子' hors“pandas dataframe to csv"'时报错,报错信息:
Error: HorsError { repr: Network(Error(Io(Custom { kind: TimedOut, error: StringError("timed out") }), "https://www.bing.com/search?q=site:stackoverflow.com%20pandas%20dataframe%20to%20csv")) }
已确认在连网情况在操作,并且可在浏览器中打开报错信息中的网址。
According to this comment: #65 (comment)
Relative to rust rand issue. Mark it for now.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.