|
Tutorial of GCLI - Generated Offline Version of
https://herrhotzenplotz.de/gcli/tutorial
Installing GCLIThrough package managerIf you’re on FreeBSD you can just install gcli by running the following command: # pkg install gcli On NetBSD you can run: # pkgin install gcli On Ubuntu, Debian, Devuan and the like you can run: # apt install gcli On ArchLinux you can either use the AUR manually or use your favourite AUR helper: # yay -S gcli Compile the source codeOther operating systems may currently require manual compilation and installation. Windows NT NotesIt is entirely possible to build gcli on Windows using MSYS2. Please follow their instructions on how to set up a development environment. Generic build instructionsFor this purpose go to https://herrhotzenplotz.de/gcli/releases and choose the latest release. Then download one of the tarballs. For version 1.1.0 this would be: https://herrhotzenplotz.de/gcli/releases/gcli-1.1.0/gcli-1.1.0.tar.xz Now that you have a link, you can download it, extract it, compile the code and install it: $ mkdir ~/build $ cd ~/build $ curl -4LO https://herrhotzenplotz.de/gcli/releases/gcli-1.1.0/gcli-1.1.0.tar.xz Install the dependencies for building gcli: e.g. on Debian systems: # apt install libcurl4-openssl-dev pkgconf build-essential or on MSYS2: $ pacman -S libcurl-devel pkgconf Extract the tarball: $ tar xf gcli-1.1.0.tar.xz $ cd gcli-1.1.0 Configure, build and install gcli: $ ./configure ... $ make ... $ make install Check that the shell finds gcli: $ which gcli /usr/local/bin/gcli $ $ gcli version gcli 1.1.0 (amd64-unknown-freebsd13.2) Using libcurl/8.1.2 OpenSSL/1.1.1t zlib/1.2.13 libpsl/0.21.2 (+libidn2/2.3.4) libssh2/1.11.0 nghttp2/1.53.0 Using vendored pdjson library Report bugs at https://gitlab.com/herrhotzenplotz/gcli/. Copyright 2021, 2022, 2023 Nico Sonack <nsonack@herrhotzenplotz.de> and contributors. $ Advanced Windows Environment SetupIn case you want to use the installed gcli from outside MSYS2 (e.g. in cmd.exe) you may wish to update the Path environment variable and add the C:\msys2\usr\bin directory to it. Make sure you have the library paths set up correctly. First stepsListing issuesLet’s start off by listing some issues - here for the curl project which is hosted on GitHub under curl/curl. To list issues for it one would run: $ gcli -t github issues -o curl -r curl You will see the list of the 30 most recent open issue tickets. The command above does the following:
Note that the -t github option goes before the issues subcommand because it is a global option for gcli that affects how all the following things like subcommands operate. However, now I also want to see closed issues: $ gcli -t github issues -o curl -r curl -a The -a option will disregard the status of the issue. Oh and the screen is a bit cluttered by all these tickets - let’s only fetch the first 10 issues: $ gcli -t github issues -o curl -r curl -n10 Searching for issuesBefore reporting a bug or looking for solutions to a problem that you found in a program you may want to search for issues. Let’s search for avast in curl/curl: $ gcli -t github issues -o curl -r curl -a avast NUMBER NOTES STATE TITLE As you can see searching for something is just a matter of appending keywords to the issues subcommand. You can specify any amount of search terms - they will all be used in the query. Again, -a ignores the status of the issue such that we also see closed tickets. Examining issuesAs of now we only produced lists of issues. However, we may also want to look at the details of an issue such as:
Let’s get a good summary of issue #11268 in the curl project: $ gcli -t github issues -o curl -r curl -i 11268 all As you can see most of the options are the same, however now we tell gcli with the -i 11268 option that we want to work with a single issue. Then we tell gcli what actions to perform on the issue. Another important action is comments. Guess what it does: $ gcli -t github issues -o curl -r curl -i 11268 comments I know a person that likes to post long verbose traces. Let’s search for an issue authored by them on the OpenSSL GitHub page: $ gcli -t github issues -o openssl -r openssl -A blastwave -a NUMBER STATE TITLE The -A option lets you filter for specific authors. Let’s look at the issue state of #10547: $ gcli -t github issues -o openssl -r openssl -i 10547 status That’s nine comments - let’s read the original post and the comments in our favourite pager less: $ gcli -t github issues -o openssl -r openssl -i 10547 op comments | less As you can see gcli will accept multiple actions for an issue and executes them sequentially. How to find documentationWhen using gcli one may not always remember all the options and flags for every subcommand. gcli has lots of integrated help to guide you through its commands. Subcommand helpYou can list all available options for the issues subcommand by doing: $ gcli issues --help With your current knowledge you can also explore the gcli pulls subcommand. General usageRun the following command: $ gcli --help usage: gcli [options] subcommand OPTIONS: This gives you an overview over all the available subcommands. Each subcommand in turn allows you to get its usage by supplying the --help option to it. Manual pagesFurthermore I recommend reading into the manual page gcli-issues(1) and gcli-pulls(1): $ man gcli-issues $ man gcli-pulls Setting up gcli for use with an accountCreating issues on GitHub requires an account which we need to generate an authentication token for gcli. If you want to test this with a different forge than GitHub look at the tutorial for other forges. Log into your GitHub account and click on your account icon in the top right corner. Then choose the Settings option. Scroll down and choose Developer settings on the bottom of the left column. Under Personal access tokens choose Tokens (classic). Click on Generate new token (classic). Set a useful name such as gcli in the Note field, set the expiration to No expiration and allow the following Scopes:
Then create the token. It’ll be printed in green. Do not share it! Now we need to tell gcli about this new token. To do this, create a configuration file for gcli - on Windows you need to do this from the MSYS2 Shell: $ mkdir -p ${HOME}/.config/gcli
$ vi ${HOME}/.config/gcli/config
Obviously, you can choose any other editor of your choice. Put the following into this file: defaults {
Replace the <token-goes-here> with the previously generated token and the <account> with your account name. If you now run $ gcli -t github repos you should get a list of your repos. If not, check again that you did all the steps above correctly. Creating an issueNote: This assumes you have configured gcli with an account for GitHub already. PreparationFor this case I have a playground repository that you may as well use for testing with gcli. It is available at herrhotzenplotz/ghcli-playground. To see a list of issues, we can run: $ gcli -t github issues -o herrhotzenplotz -r ghcli-playground -a NUMBER NOTES STATE TITLE Invoke gcliLet’s create a bug report where we complain about things not working: $ gcli -t github issues create -o herrhotzenplotz -r ghcli-playground \ The message “Bug: doesn’t work on my machine” is the title of the issue. Original PostYou will see the default editor come up and instruct you to type in a message. This message is the “original post” or the body of the issue ticket that you’re about to submit. You can use Markdown Syntax:
Submit the issueAfter you save and exit the editor gcli gives you a chance to check back and finally submit the issue. Type ‘y’ and hit enter. You can check back if the issue was created and also view details about it as you learned earlier. CommentingDiscussions on GitHub and the like are done through comments. You can comment on issues and pull requests. Reviewing a discussionSay you were looking at an issue in curl/curl: $ gcli issues -o curl -r curl -i 11461 comments Create the commentAnd now you wish to respond to this thread: $ gcli comment -o curl -r curl -i 11461 This will now open the editor and lets you type in your message. After saving and exiting gcli will ask you to confirm. Type ‘y’ and hit enter: $ gcli -t github comment -o curl -r curl -i 11461 You will be commenting the following in curl/curl #11461: Is this okay? [yN] y $ Commenting on pull requestsWhen you want to comment under a pull request use the -p flag instead of the -i flag to indicate the PR number. Creating a pull requestCreating a pull request with gcli is usually as simple as running $ gcli pulls create PreparationSuppose you have a git repository forked and cloned: $ git clone git@github.com:contour-terminal/contour $ cd contour $ gcli forks create --into herrhotzenplotz Then you do some work on whatever feature you’re planning to submit: $ git checkout -b my-amazing-feature <hackhackhack> $ git add -p $ git commit Create the pull requestNow you can run the command to create the pull request: $ gcli pulls create From (owner:branch) [herrhotzenplotz:my-amazing-feature]: Owner [contour-terminal]: Repository [contour]: To Branch [master]: Title: Add new amazing feature Enable automerge? [yN]: Most of the defaults you should be able to simply accept. This assumes that you have the source branch checked out locally and remotes are configured appropriately. Otherwise you can just change the defaults by entering the correct values. Enter original postAfter you entered all the meta data of the pull request gcli will drop you into your editor and lets you enter a message for the pull request. SubmitAfter you saved and exit type y and hit enter to submit the pull request. Other forges and bugtrackersgcli is capable of not only interacting with Github. It also currently supports:
NotesBugzilla is commonly used as a bug tracker in various large open-source projects such as FreeBSD, the Linux Kernel, Mozilla and Gentoo. SearchingSuppose you want to search for bug reports containing sparc in the Gentoo Bugzilla. In this case you need to configure an account that points at the correct URL in $HOME/.config/gcli/config by adding: gentoo {
Now you can search the Gentoo Bugs: $ gcli -a gentoo issues sparc NUMBER NOTES STATE TITLE 924443 0 UNCONFIRMED Add keyword ~sparc for app-misc/fastfetch 924430 0 RESOLVED media-libs/assimp-5.3.1 fails tests on sparc 924215 0 CONFIRMED dev-libs/libbson dev-libs/mongo-c-driver: alpha arm ia64 mips ppc ppc64 s390 sparc keyword req 924191 0 CONFIRMED media-libs/exempi: unaligned access causes dev-python/python-xmp-toolkit-2.0.2 to fails tests on sparc (test_file_to_dict (test.test_core_unit.UtilsTestCase.test_file_to_dict) ... Bus error) 924180 0 CONFIRMED dev-python/psycopg-3.1.17[native-extensions] fails tests on sparc: tests/test_copy_async.py::test_read_rows[asyncio-names-1] Fatal Python error: Bus error 924031 0 IN_PROGRESS sys-apps/bfs: ~arm ~arm64 ~ppc ~ppc64 ~sparc keywording 923968 0 CONFIRMED dev-python/pyarrow-15.0.0 fails to configure on sparc: CMake Error at cmake_modules/SetupCxxFlags.cmake:42 (message): Unknown system processor 921245 0 CONFIRMED media-video/rav1e-0.6.6 fails to compile on sparc: Assertion `DT.dominates(RHead, LHead) && "No dominance between recurrences used by one SCEV?"' failed. 920956 0 CONFIRMED dev-python/pygame-2.5.2: pygame.tests.font_test SIGBUS on sparc 920737 0 CONFIRMED sparc64-solaris Prefix no longer supported <snip> Issue detailsFurthermore we can look at single issues: $ gcli -a gentoo issues -i 920737 all comments Configuring an account for use with a tokenFirst you need to generate a token:
Now click Create personal access token. Save this token - do not share it with anyone else. You can now update your gcli config in $HOME/.config/gcli/config: defaults {
After that you should be able to run the following command: $ gcli -t gitlab issues -o herrhotzenplotz -r gcli If this process errors out check the above steps. If you believe this is a bug, please report it at our issue tracker! GiteaThe steps here are roughly the same as with GitLab. To generate a token:
You can now update your gcli config file in $HOME/.config/gcli/config: defaults {
The example here uses Codeberg. Update these fields as needed for your own use case.
|