From 54e3273d571a870bdf44e6d90e4f28d38f2e5b5f Mon Sep 17 00:00:00 2001 From: James Date: Wed, 26 Jun 2019 10:00:56 +0100 Subject: [PATCH] add cmd line args and comments --- no_label_milestone.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/no_label_milestone.php b/no_label_milestone.php index f41db63..c6d5046 100644 --- a/no_label_milestone.php +++ b/no_label_milestone.php @@ -8,15 +8,24 @@ include("src/Label.php"); include("src/Repo.php"); $config=include("config.php"); -$client=new Client($config['url'],$config['user'],$config['pass'],true); -$repo=$client->getRepo('james','test'); +//pass cmd line args +if($argc<3){ + die(basename(__FILE__)." [debug]\n"); +} +$debug = ($argc==4 && $argv[3]=='debug'); +//open connection and repo +$client=new Client($config['url'],$config['user'],$config['pass'],$debug); +$repo=$client->getRepo($argv[1],$argv[2]); + +//get the labels of interest $nolabelLabel=$repo->getLabelByName('no-label'); if(!$nolabelLabel) die ("Can't find 'no-label' label in repo\n"); $nomilestoneLabel=$repo->getLabelByName('no-milestone'); if(!$nomilestoneLabel) die ("Can't find 'no-milestone' label in repo\n"); +//define the function to process each issue $callback=function($issue) use ($nolabelLabel,$nomilestoneLabel){ // do the no-label thing $labelCount=count($issue->getData()->labels); @@ -35,4 +44,5 @@ $callback=function($issue) use ($nolabelLabel,$nomilestoneLabel){ } }; +//loop through issues and call the callback $repo->forIssues($callback);