A simple CLI Client

I would like to make a simple CLI to quickly add tasks and subtasks without using the browser, so I have a few questions:

  1. Is there a good way to authenticate via OIDC when calling a script (e.g. Google has a workflow where you can quickly authenticate an external application from the browser)?
    I looked in the API docs, but these seem to require already having made a call to the provider. Basically I want to prompt the user to login and then get the token out somehow, without having to copy it from the network log.
  2. Is the handling of quick add magic available in the api, and if not could that be made available there?

But maybe, somebody has built something like this already, or even a generalized task cli (thinking about something like a taskwarrior integration, which already has lots of magic handling I think…) one could build upon.
I would be astonished if all the power-users here work solely from the browser with this great application :wink:

2 Likes

I think most other cli clients (like the stripe cli, for example) solve this by starting a web server and authenticating in the browser, then save the obtained api token to some place where the cli can access it.

Right now it’s not implemented in the api. It will be at some point though.

Hey @xeruf !

Did you manage to make the CLI ?
I would love to have a quicker way to add tasks to Vikunja without opening and navigating to my instance :smiley:

I put some work recently into a command line client for Vikunja. It’s written in python.

While it still lacks some features, especially concerning grouping and sorting of output, I think it might be worth to give it a try.

2 Likes

Finally got around to test this properly, really nice work!

What would you say is the status of it? Should we add it to the docs?

I am pretty happy with using it on a daily schedule. Right now, my personal backlog of features left to add gets smaller (and/or more boring…) Definitely, I should provide more options for filtering/grouping/sorting the ls output. But I am still not sure how to that properly in a CLI.
So maybe this is a good time to get some feedback. It would be an honor if you would link to it in your docs :slight_smile:

1 Like

Hello cernst72,

I came to Vikunja from topydo, which is quite a capable todo CLI client… if you are interested, I’d like to port some of the features from topydo to vja…

Thoughts?
\mike

Dear mpenning, I haven’t noted topydo before. Seems quite solid and definitely something to learn from.

Of course, you can port features to/from it as you like. Maybe just via Merge Request? What would be your favorite features to consider?

todo.txt would be a big thing for a cli but that also sounds like a lot of work with little benefit. And we may add parsing for that into the api at which point it won’t make sense to have it built manually into the cli.

I mean, you put in all the work to build the CLI, the least I can do is add it to the docs :slight_smile:

Do you have an idea about where to add it? Maybe even on a dedicated page?

Dear kolaente, I agree vja is intended to be a Vikunja client, not a wrapper.
Concerning the link, it’s really up to you. Maybe put it on the download page in a block “Contributions” or “3rd party”? Maybe a separate page for that?
As of now, it seems better to consider it external. vja suits more or less my own needs. If it was improved and become more configurable, one could even think of making it an official part of Vikunja. But this again is up to you.

I’ve added a mention it on the downloads page: Download | Vikunja

I’d love to incorporate it into Vikunja, maybe once you’re confident it is done?

Thanks, I had not checked in here in a while!
Please, though, don’t make me create a dir in my HOME, and incorporate XDG instead :slight_smile: xdg-base-dirs · PyPI

Oh, and if a nonexistent api_url would automatically be derived from the frontend-url that would be awesome as well!

Oh, I can’t use it yet, our instance only allows OIDC signin :confused:

I’m using vja as a CLI client for my Vikunja instance and it’s working very well, great work!

My only fear is my login token running out - I have an automated system and would like to understand how I could effectively make it permanent?

The easiest would probably be to extend the token lifetime: Config options | Vikunja

I’m not sure about how vja handles token renewal, but the api is also able to “trade” a token close to expiry to a new one which would be valid 3 more days from the time of the renewal (that’s what the web frontend does). It’s alspo possible to return a long token when logging in which is valid a lot longer than the default - that’s something vja would need to do.

When vja has no token or the token has become invalid it will prompt for credentials and fetch a new token. Future versions will fetch the long token with a default lifetime of 30 days. At the moment the token is valid for 3 days by default.
Additionally, you may use --username and --password like vja -u demo -p demo ls if this suits your needs better

Note: You can call vja logout which just deletes the stored token,

Configuration file and token are stored in directory $HOME/.vjacli by default. But you may change that via export VJA_CONFIGDIR=/not/my/home.

OID support is on my todo list. But honestly it might remain there for a few weeks.