diff --git a/README.md b/README.md index ceb913a..7d5e2fc 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,17 @@ This project is a small helper for mass-watching / unwatching in GitHub reposito # bundle install [...] +# ruby watch.rb help +Commands: + watch.rb help [COMMAND] # Describe available commands or one specific command + watch.rb list # lists all repos, useful to test your watch regex + watch.rb unwatch # unwatch all repos matching your regex + watch.rb watch # watch all repos matching your regex + watch.rb watched # show all watched repos, useful to test your unwatch regex + +Options: + [--token=TOKEN] + # ruby watch.rb list --token= Luzifer/alarmclock Luzifer/alfred-fold @@ -25,14 +36,11 @@ Luzifer/AMZWishlist Luzifer/awsenv [...] -# ruby watch.rb watch '^Luzifer/.*' --token= -Subscribing to Luzifer/blog.knut.me... -Subscribing to Luzifer/go-selfupdate... -Subscribing to Luzifer/golang-builder... -Subscribing to Luzifer/habitrpg... -Subscribing to Luzifer/homebrew... -Subscribing to Luzifer/homebrew-tools... -Subscribing to Luzifer/license... -Subscribing to Luzifer/radiopi... -Subscribing to Luzifer/simpleproxy... +# ruby watch.rb list '^Luzifer/alfred-.*' --token= +Luzifer/alfred-fold +Luzifer/alfred-pwdgen + +# ruby watch.rb watch '^Luzifer/alfred-.*' --token= +Subscribing to Luzifer/alfred-fold... +Subscribing to Luzifer/alfred-pwdgen... ``` diff --git a/watch.rb b/watch.rb index a821181..534f3b9 100755 --- a/watch.rb +++ b/watch.rb @@ -26,7 +26,7 @@ class WatchCLI < Thor get_repos().each do |repo| if !subscriptions.include?(repo.full_name) and /#{regex}/.match(repo.full_name) puts "Subscribing to #{repo.full_name}..." - get_octokit().update_subscription(repo.full_name, {subscribed: true}) + get_octokit().update_subscription(repo.full_name, {subscribed: true}) end end end @@ -35,8 +35,10 @@ class WatchCLI < Thor def unwatch(regex) subscriptions = get_subscriptions() get_repos().each do |repo| - puts "Unsubscribing from #{repo.full_name}..." - get_octokit().update_subscription(repo.full_name, {subscribed: false}) if subscriptions.include?(repo.full_name) and /#{regex}/.match(repo.full_name) + if subscriptions.include?(repo.full_name) and /#{regex}/.match(repo.full_name) + puts "Unsubscribing from #{repo.full_name}..." + get_octokit().delete_subscription(repo.full_name) + end end end @@ -53,9 +55,9 @@ class WatchCLI < Thor def get_repos client = get_octokit - + repos = client.repositories(client.user.login) - + orgs = client.organizations() orgs.each do |org| client.organization_repositories(org.login).each do |repo|