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

Add source field to each cheatpath to describe cheatsheet's source #658

Open
Lonenso opened this issue Mar 19, 2022 · 0 comments
Open

Add source field to each cheatpath to describe cheatsheet's source #658

Lonenso opened this issue Mar 19, 2022 · 0 comments

Comments

@Lonenso
Copy link

Lonenso commented Mar 19, 2022

Is your feature request related to a problem? Please describe.
I was trying to sync cheatsheets between devices, so I put my conf.yml to my dotfiles. Suddenly, I realized that I still have to sync the community's cheatsheets manually(clone it) because the config only describes cheatsheets' locations.

Describe the solution you'd like
Add source field to each cheatpath like below, then we may have the ability to init/update cheatsheets, then users don't need to clone the repo manually.

This gives cheat the ability to describe cheatsheet's source, cheat may be able to manage cheatsheets without this helper scripts

- name: community
  path: ~/cheatsheets/community
  source: https://github.com/cheat/cheatsheets.git    # <-- add this 
  tags: [ community ]
  readonly: true

Describe alternatives you've considered
Still needs to add a field to config to describe cheatsheet's source but let this helper scripts to manage cheatsheets.

I think this alternative have the minimum changes and more flexible.

  • cheat: load/edit/save cheatsheets
  • cheat helper scripts: init/update cheatsheets
init() {
  readarray d < <(yq -c '.cheatpaths[]' ~/.cheat.yml)  # here's a hard code for cheat's config, I think we need an command option to show what exactly the cheat is using. Just like nginx -t
  for c in "${d[@]}"; 
  do
      name="$(echo ${c} | yq -r '.name')"
      path="$(echo ${c} | yq -r '.path')"
      src="$( echo ${c} | yq -r '.source')"

      echo "Init $name"
      [ ! -d "$path" ] && git clone $src $path || :
  done
  echo "Finished init"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant