Skip to content

Commit

Permalink
v1.14.0 added listing repos with issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Colum Paget committed Jan 16, 2024
1 parent ebd527d commit 8a6c751
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 63 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
v1.14.0 (2024-01-16)
* add support for listing all repos with issues (githuber.lua repo issues)
* fix 'invalid format string' errors in recent lua versions
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ Githuber is usually run within the lua interpreter. e.g.
lua githuer.lua notify
```

Available commands are:
alternatively you can configure linux's "binfmt" system to auto-run scripts ending in '.lua'


## COMMANDS

```
githuber.lua account set name - set user's display-name
Expand All @@ -67,29 +70,29 @@ Available commands are:
githuber.lua notify stars - list user's stars notifications
githuber.lua issues - list all open issues acrosss all user's repos
githuber.lua repo list - list user's repositories
githuber.lua repo names - list user's repositories, just the names on seperate lines
githuber.lua repo snames - list user's repositories, just the names seperated by spaces
githuber.lua repo urls - list user's repositories, just the urls on seperate lines
githuber.lua repo surls - list user's repositories, just the urls seperated by spaces
githuber.lua repo details - list user's repositories with traffic details
githuber.lua repo details [repo] - detailed info for a repository
githuber.lua repo issues - list user's repositories that have issues
githuber.lua repo issues [repo] - list issues for a specific repository
githuber.lua repo names - list user's repositories, just names, one name per line, for use in scripts
githuber.lua repo urls - list user's repositories, just urls, one url per line, for use in scripts
githuber.lua repo snames - list user's repositories, just names, all in one line, for use in scripts
githuber.lua repo surls - list user's repositories, just urls, all in one line, for use in scripts
githuber.lua repo new [name] [description] - create new repository
githuber.lua repo create [name] [description] - create new repository
githuber.lua repo set [repo] description [description] - change description for a repository
githuber.lua repo set [repo] homepage [homepage] - change homepage for a repository
githuber.lua repo set [repo] topics [topics] - change topics for a repository
githuber.lua repo del [repo] - delete repository
githuber.lua repo delete [repo] - delete repository
githuber.lua repo rm [repo] - delete repository
githuber.lua repo merge [repo] [pull number] - merge a pull request by its pull number
githuber.lua repo watchers [repo] - list repo watchers
githuber.lua repo commits [repo] - list repo commits
githuber.lua repo history [repo] - list repo commits and releases
githuber.lua repo issues [repo] - list repo issues
githuber.lua repo pulls [repo] - list repo pull requests
githuber.lua repo pulls [repo] merge [pull number] - merge a pull request by its pull number
githuber.lua repo forks [repo] - list repo forks
githuber.lua repo topics [repo] - list repo topics
githuber.lua repo settopics [repo] [topic] [topic]... - set repo topics, this doesn't add, it sets a new list
githuber.lua preq [repo] [title] - issue a pull request to parent repo
githuber.lua star [url] - 'star' (bookmark) a repo by url
githuber.lua unstar [url] - remove a 'star' (bookmark) of a repo by url
Expand All @@ -102,7 +105,6 @@ Available commands are:
githuber.lua releases [repo] del [name] - delete release for a repository
githuber.lua releases [repo] delete [name] - delete release for a repository
githuber.lua releases [repo] rm [name] - delete release for a repository
```

The "repo names", "repo snames", "repo urls" and "repo surls" commands are intended for use in scripting. "repo names" and "repo urls" use newline as a separator (so one item per line) whereas "repo snames" and "repo surls" use space as a separator. For instance, you can back up all your github repositories with a script like this:
Expand Down
101 changes: 47 additions & 54 deletions githuber.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require("time")


-- program version
VERSION="1.13.0"
VERSION="1.14.0"

-- USER CONFIGURABLE STUFF STARTS HERE --
-- Put your username here, or leave blank and use environment variable GITHUB_USER instead
Expand Down Expand Up @@ -147,7 +147,7 @@ if strutil.strlen(id) ==0 then id=I:value("id") end
if strutil.strlen(id) ==0 then return nil end

Issue.what=I:value("type")
Issue.id=string.format("%- 9s", id)
Issue.id=string.format("%-9s", id)
Issue.who=I:value("actor/login")
if strutil.strlen(Issue.who) == 0 then Issue.who=I:value("user/login") end
Issue.where=I:value("repository/name")
Expand Down Expand Up @@ -319,7 +319,7 @@ local State
else State="~rOPEN~0"
end

Out:puts(Event.id .." ".. State.." since " .. time.formatsecs("%Y/%m/%d",Event.when) .. " by ".. string.format("%- 15s", Event.who) .. " " .. Event.where .. " " .. title_color .. "'" .. Event.why.."~0' ".. "comments: "..Event.no_of_comments.."\r\n url: "..Event.url.."\r\n")
Out:puts(Event.id .." ".. State.." since " .. time.formatsecs("%Y/%m/%d",Event.when) .. " by ".. string.format("%-15s", Event.who) .. " " .. Event.where .. " " .. title_color .. "'" .. Event.why.."~0' ".. "comments: "..Event.no_of_comments.."\r\n url: "..Event.url.."\r\n")
if strutil.strlen(Event.diff) > 0
then
Out:puts(" diff: "..Event.diff.." patch: "..Event.patch .. "\r\n")
Expand Down Expand Up @@ -775,23 +775,30 @@ do
then
if list_type == "names"
then
name=strutil.quoteChars(name, " `'$\"")
name=strutil.quoteChars(name, " `'$\"")
Out:puts(name.."\r\n")
elseif list_type == "snames"
then
name=strutil.quoteChars(name, " `'$\"")
name=strutil.quoteChars(name, " `'$\"")
Out:puts(name.." ")
elseif list_type == "urls"
then
name=strutil.quoteChars(I:value("html_url"), " `'$\"")
name=strutil.quoteChars(I:value("html_url"), " `'$\"")
Out:puts(name.."\r\n")
elseif list_type == "surls"
then
name=strutil.quoteChars(I:value("html_url"), " `'$\"")
name=strutil.quoteChars(I:value("html_url"), " `'$\"")
Out:puts(name.." ")
elseif list_type == "issues"
then
if tonumber(P:value("open_issues")) > 0
then
Out:puts(GithubFormatRepo(I, detail))
Out:puts("\r\n")
end
else
Out:puts(GithubFormatRepo(I, detail))
Out:puts("\r\n")
Out:puts("\r\n")
end
end

Expand All @@ -800,14 +807,20 @@ end

end

function GithubRepositories(user, args)

if args[2]=="create" or args[2]=="new"
then
GithubRepoCreate(user, args[3], args[4])
elseif args[2]=="del" or args[2]=="delete" or args[2]=="rm"
then
GithubRepoDelete(user, args[3])
function GithubRepoActions(user, args)

if args[2]=="create" or args[2]=="new" then GithubRepoCreate(user, args[3], args[4])
elseif args[2]=="del" or args[2]=="delete" or args[2]=="rm" then GithubRepoDelete(user, args[3])
elseif args[2]=="merge" then GithubRepoPullMerge(user, args[3], args[4])
elseif args[2]=="watchers" then GithubRepoListWatchers(user, args[3])
elseif args[2]=="forks" then GithubRepoListForks(user, args[3])
elseif args[2]=="pulls" then GithubRepoPulls(user, args[3], args[4], args[5])
elseif args[2]=="topics" then GithubRepoTopics(user, args[3])
elseif args[2]=="history" then GithubRepoCommitsList("history", user, args[3])
elseif args[2]=="commits" then GithubRepoCommitsList("commits", user, args[3])
elseif args[2]=="issues" then GithubIssuesURL("https://" .. GithubUser .. ":" .. GithubAuth .. "@api.github.com/repos/"..GithubUser.."/"..args[3].."/issues?state=all",true)
elseif args[2]=="details" then GithubRepoInfo(user, args[3])
elseif args[2]=="set"
then
if args[4]=="topics"
Expand All @@ -816,48 +829,21 @@ then
else
GithubRepoSet(user, args[3], args[4], args[5])
end
elseif args[2]=="merge"
then
GithubRepoPullMerge(user, args[3], args[4])
elseif args[2]=="watchers"
then
GithubRepoListWatchers(user, args[3])
elseif args[2]=="forks"
then
GithubRepoListForks(user, args[3])
elseif args[2]=="pulls"
then
GithubRepoPulls(user, args[3], args[4], args[5])
elseif args[2]=="topics"
then
GithubRepoTopics(user, args[3])
elseif args[2]=="history"
then
GithubRepoCommitsList("history", user, args[3])
elseif args[2]=="commits"
then
GithubRepoCommitsList("commits", user, args[3])
elseif args[2]=="issues"
then
GithubIssuesURL("https://" .. GithubUser .. ":" .. GithubAuth .. "@api.github.com/repos/"..GithubUser.."/"..args[3].."/issues?state=all",true)
elseif args[2]=="details"
then
if strutil.strlen(args[3]) > 0
then
GithubRepoInfo(user, args[3])
else
GithubRepoList(user, args[2])
end
elseif args[2] == "names" or args[2] == "urls" or args[2] == "snames" or args[2] == "surls"
then
GithubRepoList(user, args[2])
else
GithubRepoList(user, "")
end


end


function GithubRepositories(user, args)

if args[2] == "names" or args[2] == "urls" or args[2] == "snames" or args[2] == "surls" then GithubRepoList(user, args[2])
elseif args[2] == "details" then GithubRepoList(user, args[2])
elseif args[2] == "issues" then GithubRepoList(user, args[2])
else GithubRepoList(user, "")
end

end

-- target can be 'name', 'email', 'bio'
function GithubAccountSet(user, target, args)
Expand Down Expand Up @@ -1108,6 +1094,8 @@ print(" githuber.lua issues - lis
print(" githuber.lua repo list - list user's repositories")
print(" githuber.lua repo details - list user's repositories with traffic details")
print(" githuber.lua repo details [repo] - detailed info for a repository")
print(" githuber.lua repo issues - list user's repositories that have issues")
print(" githuber.lua repo issues [repo] - list issues for a specific repository")
print(" githuber.lua repo names - list user's repositories, just names, one name per line, for use in scripts")
print(" githuber.lua repo urls - list user's repositories, just urls, one url per line, for use in scripts")
print(" githuber.lua repo snames - list user's repositories, just names, all in one line, for use in scripts")
Expand All @@ -1124,7 +1112,6 @@ print(" githuber.lua repo merge [repo] [pull number] - mer
print(" githuber.lua repo watchers [repo] - list repo watchers")
print(" githuber.lua repo commits [repo] - list repo commits")
print(" githuber.lua repo history [repo] - list repo commits and releases")
print(" githuber.lua repo issues [repo] - list repo issues")
print(" githuber.lua repo pulls [repo] - list repo pull requests")
print(" githuber.lua repo pulls [repo] merge [pull number] - merge a pull request by its pull number")
print(" githuber.lua repo forks [repo] - list repo forks")
Expand Down Expand Up @@ -1184,7 +1171,13 @@ then
if GithubCheckUser(GithubUser) then GithubAccount(GithubUser, arg) end
elseif arg[1]=="repo" or arg[1] == "repos"
then
if GithubCheckUser(GithubUser) then GithubRepositories(GithubUser, arg) end
if GithubCheckUser(GithubUser)
then
-- args[3] is the repo name, if there isn't one then it's a 'list repos' function
if strutil.strlen(arg[3]) > 0 then GithubRepoActions(GithubUser,arg)
else GithubRepositories(GithubUser, arg)
end
end
elseif arg[1]=="releases"
then
if GithubCheckUser(GithubUser) then GithubRepoReleases(GithubUser, arg[2], arg) end
Expand Down

0 comments on commit 8a6c751

Please sign in to comment.