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

Feature Request: Commands to display info for a library #359

Open
nrobinson2000 opened this Issue Apr 17, 2017 · 8 comments

Comments

Projects
None yet
2 participants
@nrobinson2000
Copy link

nrobinson2000 commented Apr 17, 2017

I think It would be great if there were commands to get the metadata for a library, like the Github URL, Author, Description, and Stats just like you can get from the Web IDE. It would be best if there were options to get only a specific field.

The command could be info, and one would be able to use it through:

particle library info NAME_OF_LIB

Flags could be used to explicitly request certain fields. For example if you wanted to find the Github URL for the neopixel library you could use:

particle library info neopixel --url

And particle-cli would output only https://github.com/technobly/Particle-NeoPixel, for ease of use with scripts like po-util.

I really like using Particle Libs 2.0, and I feel like the info command is a required feature.


Credit: @mrmowgli for suggesting that I make this feature request.

@monkbroc

This comment has been minimized.

Copy link
Member

monkbroc commented Apr 18, 2017

Very good idea. Thanks for the nice spec Nathan!

@nrobinson2000

This comment has been minimized.

Copy link

nrobinson2000 commented Apr 20, 2017

@monkbroc Thanks for the support. I hope this won't be too difficult to implement.

@nrobinson2000

This comment has been minimized.

Copy link

nrobinson2000 commented Apr 25, 2017

I would try to implement this myself, but I'm terrible with NodeJS, but I want to learn it.

I presume the command could use the library API to get the info: https://docs.particle.io/reference/api/#libraries

@nrobinson2000

This comment has been minimized.

Copy link

nrobinson2000 commented May 3, 2017

Any updates on this?

@monkbroc

This comment has been minimized.

Copy link
Member

monkbroc commented May 5, 2017

We are tracking this task but have not started the development yet.

@nrobinson2000

This comment has been minimized.

Copy link

nrobinson2000 commented May 5, 2017

Awesome.

@nrobinson2000

This comment has been minimized.

Copy link

nrobinson2000 commented Jun 21, 2017

I've now made this a feature of po-util. Using the following function, po-util will attempt to find the URL of a library, and if it is a github link it will ask you if you'd like to download the library repository using git instead of downloading a release with particle-cli:

getLibURL()
{
  TOKEN="$(cat ~/.particle/particle.config.json | grep 'token' | grep -oE '([0-Z])\w+' | grep -v 'token')"
  DATA=$(curl -sLH "Authorization: Bearer $TOKEN" "https://api.particle.io/v1/libraries/$1" | json_pp)
  LIBURL=$(echo "$DATA" | grep "url" | grep -oE '"((?:\\.|[^"\\])*)"' | grep "http" |  tr -d '"')
}

Here is how/where getLibURL is actually used within po-util when downloading a library:

getLibURL "$LIB_QUERY"

if  ( echo "$LIBURL" | grep "github" ) > /dev/null ;
then
  green_echo "$LIB_QUERY is availiable on GitHub!"
  read -rp "Would you prefer to download it this way? (yes/no): " answer

  if [ "$answer" == "yes" ] || [ "$answer" == "y" ] || [ "$answer" == "Y" ];
  then
    echo
    cd "$LIBRARY"
    git clone "$LIBURL" "$LIB_QUERY"
    echo
    blue_echo "Downloaded $LIB_QUERY from GitHub."
    return 0
  fi
  echo
fi

I love bash.

@nrobinson2000

This comment has been minimized.

Copy link

nrobinson2000 commented Aug 21, 2017

Here is a snippet for searching for a library's GitHub URL quickly if anyone is looking for it.

https://gist.github.com/nrobinson2000/f77a32c04c2fb9540c658a17009276f4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment