tanakh / cargo-atcoder

Cargo subcommand for AtCoder
BSD 3-Clause "New" or "Revised" License
397 stars 36 forks source link

Feature to open webpages and source files #51

Open qryxip opened 3 years ago

qryxip commented 3 years ago

私が作っているcargo-competeでは

  1. 問題のページをブラウザで
  2. 各ソースファイルの.rsとテストファイルの.ymlを任意のエディタで

開けるようにしています。思いの他体験が良いのでcargo-atcoderでもどうでしょうか。

GIF

ただ1.はCargoでも使われているopenerで良いとして、2.を任意のエディタに対して提供しようとすると設定がちょっと面倒ですね。

こういうのを思いついたのでcargo-competeはそうしたんですが

# Open files with the command (`jq` command)
#
# Emacs:
open = '["emacsclient", "-n"] + (.paths | map([.src, .test_suite]) | flatten)'

VSCodeがこうなってしまい後悔しています。(-aを一緒にまとめるとrust-analyzer拡張が変なエラーを出したりして体験が悪い。VSCodeを常用していないので気づきませんでした)

# VSCode:
open = '["bash", "-c"] + ["code -a " + .manifest_dir + " && code " + (.paths | map([.src, .test_suite]) | flatten | join(" "))]'

(edit) こうしたら普通に解決しました (https://github.com/qryxip/cargo-compete/pull/71)

# Open files with the command (`jq` command that outputs `string[] | string[][]`)
open = '[["code", "-a", .manifest_dir], ["code"] + (.paths | map([.src, .test_suite]) | flatten)]'