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

Create CLI command builder with metatable #810

Merged
merged 5 commits into from
Jan 20, 2025

Conversation

wd60622
Copy link
Collaborator

@wd60622 wd60622 commented Jan 19, 2025

Describe what this PR does / why we need it

This adds a metatable to the octo.gh module which allows for building commands more closely to the CLI commands.

For instance,

local gh = require "octo.gh"

local print_response = function(stdout, stderr)
  vim.print(stdout)
  vim.print(stderr)
end
local opts = {
  cb = print_response
}

-- gh auth status -a
gh.auth.status { 
  a = true,
  opts = opts,
}

-- gh issue list --json author,labels
gh.issue.list {
  json = "author,labels",
  opts = opts,
}

-- gh pr list --search "is:merged -label:no releasenotes"
gh.pr.list {
  search = 'is:merged -label:"no releasenotes"',
  opts = opts,
}

-- gh pr view 810 --json author,labels,title,url
gh.pr.view {
  810, 
  json = "author,labels,title,url",
  opts = opts,
}

Note

Anything in the opts table will be passed to the run function

Note

There is no validation that happens on the commands. If someone has extensions installed, They will be able to be used
gh.milestone.list will work if the extension is installed
gh.copilot.explain { "How to install nvim" } if the copilot extension is installed

Warning

Commands like gh.run.list will not work due to it being used by the module already...

Does this pull request fix one issue?

Describe how you did it

Have a metatable for the octo.gh module that allows for building commands more closely to the CLI commands.

Describe how to verify it

Special notes for reviews

Checklist

  • Passing tests and linting standards
  • Documentation updates in README.md and doc/octo.txt

@wd60622 wd60622 merged commit da764ce into pwntester:master Jan 20, 2025
3 checks passed
@wd60622 wd60622 deleted the build-cli-commands branch January 20, 2025 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant