Giter Site home page Giter Site logo

hors's People

Contributors

dancodes avatar dependabot-preview[bot] avatar dependabot[bot] avatar j-tai avatar keng42 avatar windsoilder avatar zapanton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

hors's Issues

Add clear cache

Add function to clear cache as in howdoi.

I decided by adding to my .zshrc : alias hr=' rm -rf ~/.cache/hors/* &>/dev/null'

Special formatting characters rendered as text in Windows Powershell and CMD

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}

A packaging action on every release should get in place

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.

Add proxy support

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.

Accept multiple query arguments and join with spaces

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.

Unable to compile

$ 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

Make two level cache

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)

Doesn't always highlight syntax

Doesn't always highlight syntax.

Example, query "regexp javascript" syntax highlighting well:
regexp_javascript

query "regexp php" practically does not highlight syntax:
regexp_php

Another screenshot with php syntax:
bad_highlight_php

Unreadable colors

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_colors

Hors version is 0.6.4, run under KDE, Yakuake, Sweet console theme.
I tried other themes and it was still problematic.

A bit of info on `lang-` class

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:
image
image

While an answer further down (answer-51907405) has it - but it's a snippet:
image
image

And the last answer (answer-59526105) has it but it's not a snippet:
image
image

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.

Failed with 'DuckDuckGo' and 'Google' search engines

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.

cache doesn't created when running hors

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.

Duck Duck Go seems to have parse issues on macOS at least

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.