Coder Social home page Coder Social logo

cvcap's Introduction

Note I no longer do any software dev so this repo is essentially abandoned. I'll leave it here in case it's of any use to anyone. I'd also consider transfering the repo if anyone would like to take it on.


cvcap

A minimal commandline capture tool for Checkvist

Usage

This is a summary. cvcap help shows all options

Add a task from the commandline to the default list

This form requires no subcommand, and takes no options other than -v (for verbose output)

  • cvcap "a task"

    adds a task to the top of a default list (chosen on first run)

Add a task from a choice of sources to any list

This requires use of the add subcommand

  • cvcap add "a task" -l

    adds a task to a selected list (optionally saved as a new default)

  • cvcap add -c

    adds a task from the clipboard

  • cat [file name] | cvcap add -s

    Adds a task from stdin

  • cvcap add -cl    - or -    echo "task" | cvcap add -sl

    options can be combined

Bookmarks

  • cvcap add-bookmark [bookmark name]

    Adds a bookmark to enable adding tasks to Checkvist lists other than the default list. A bookmark must already exist on the clipboard. This can be either the URL of a list (ie. copied from the browser url bar) or the URL of an item (the Checkvist copy permalink command or lc shortcut). Adding a task with an item shortcut makes a child task.

  • cvcap add [task] -b [bookmark name]

    Adds the task to the location pointed to by the bookmark

Installation

Those familiar with the Rust tookchain will find it straightforward to install from git with cargo install --git https://github.com/crispinb/cvcap/releases/tag/v0.1.5-alpha or cargo install --git https://github.com/crispinb/cvcap for the edgier version.

Earlier versions provided binaries which I've stopped updating for now. Feel free to submit an issue if you'd like binaries available.

Configuration and Environment

The default configuration file is named cvcap.toml. By default it's in the standard config location for each platform. This can be altered by setting the env var CVCAP_CONFIG_FILE_PATH to the full desired path to the file.

The Checkvist API login is stored in the logged-in user's system keyring for the platform (see https://github.com/hwchen/keyring-rs for platform details). The credential ID (however that is defined on the platform' is 'cvcap-api-token' by default. This can be changed by setting the env var CVCAP_CREDENTIAL_ID

Future plans

This is an intentionally simple tool to quickly capture text tasks to Checkvist. It will likely remain unpolished but serviceable. A few additional features I may add are:

  • File attachments
  • notes

I'm most interested though in using cvcap as inspiration for a more general-purpose capture tool, ie. a rules-driven interface to flexibly capture to a variety of sinks: checkvist, logseq, notion, etc.

Note on cvcap / Checkvist (non-)relationship

This is a third party app using Checkvist's public API. This repo has no affiliation with Checkvist (apart from recommending it heartily)

cvcap's People

Contributors

crispinb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cvcap's Issues

Capture from stdin

ie. cat file | cvcap

error if text arg is also supplied cat file | cvcap 'spurious'

can't seem to log in?

Hi,

I'm excited to try out this tool for quickly adding tasks to Checkvist. I'm trying to log in, but I'm getting the error "Couldn't get token from Checkvist API" Below is the verbose output from the error. Is there any way to unhide the text being entered into the OpenAPI key field so I can verify it is correct? I have 2-step authentication enabled, I wonder if this is the problem? Thanks!

[2022-07-12T13:56:36Z DEBUG ureq::stream] connecting to checkvist.com:443 at 89.149.211.214:443
[2022-07-12T13:56:36Z DEBUG rustls::client::hs] No cached session for DnsName(DnsName(DnsName("checkvist.com")))
[2022-07-12T13:56:36Z DEBUG rustls::client::hs] Not resuming any session
[2022-07-12T13:56:36Z DEBUG rustls::client::hs] ALPN protocol is None
[2022-07-12T13:56:36Z DEBUG rustls::client::hs] Using ciphersuite TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
[2022-07-12T13:56:36Z DEBUG rustls::client::tls12::server_hello] Server supports tickets
[2022-07-12T13:56:37Z DEBUG rustls::client::tls12] ECDHE curve is ECParameters { curve_type: NamedCurve, named_group: X25519 }
[2022-07-12T13:56:37Z DEBUG rustls::client::tls12] Server DNS name is DnsName(DnsName(DnsName("checkvist.com")))
[2022-07-12T13:56:37Z DEBUG rustls::client::tls12] Session saved
[2022-07-12T13:56:37Z DEBUG ureq::stream] created stream: TcpStream { addr: 10.8.4.165:63194, peer: 89.149.211.214:443, socket: 444 }
[2022-07-12T13:56:37Z DEBUG ureq::unit] sending request POST https://checkvist.com/auth/login.json?version=2
[2022-07-12T13:56:37Z DEBUG ureq::unit] writing prelude: POST /auth/login.json?version=2 HTTP/1.1
Host: checkvist.com
User-Agent: ureq/2.4.0
Accept: /
Content-Type: application/json
accept-encoding: gzip
Content-Length: 53
[2022-07-12T13:56:37Z DEBUG ureq::unit] response 401 to POST https://checkvist.com/auth/login.json?version=2
[2022-07-12T13:56:37Z ERROR cvcap] Fatal error. Root cause: Status(401, Response[status: 401, status_text: Unauthorized, url: https://checkvist.com/auth/login.json?version=2])

Error: Couldn't get token from Checkvist API

If you want to report this, fill out an issue at
https://github.com/crispinb/cvcap/issues.
To gather more details that might help solve issue,
run the same command again with the '-v' switch,
and copy the output into the issue.

Improve output with colours

Add "long task with a name that @#$ might be hard to distinguish" as a new task? yes Adding task "long task with a name that @#$ might be hard to distinguish" to list "@main"......... Task added
The task itself isn't very legible amongst the other output, so distinguish with colour.

Should log in again rather than error when token refresh fails

[2022-08-01T01:08:43Z DEBUG ureq::unit] writing prelude: POST /auth/refresh_token.json?version=2 HTTP/1.1
    Host: checkvist.com
    User-Agent: ureq/2.5.0
    Accept: */*
    Content-Type: application/json
    accept-encoding: gzip
    Content-Length: 25
.[2022-08-01T01:08:43Z DEBUG ureq::response] Chunked body in response
[2022-08-01T01:08:43Z DEBUG ureq::unit] response 401 to POST https://checkvist.com/auth/refresh_token.json?version=2
[2022-08-01T01:08:43Z DEBUG ureq::stream] dropping stream: Stream(RustlsStream)
[2022-08-01T01:08:43Z DEBUG ureq::stream] dropping stream: Stream(RustlsStream)

Task added
[2022-08-01T01:08:43Z ERROR cvcap] Fatal error. Cause: TokenRefreshFailedError

    Error: Could not add task

    If you want to report this, fill out an issue at 
    https://github.com/crispinb/cvcap/issues.
    To gather more details that might help solve issue, 
    run the same command again with the '-v' switch,
    and copy the output into the issue.

Consider moving to reqwest

Have avoided because I didn't need async/tokio for anything else. But I'll need it for the new sync feature, so might as well go all in

Destination aliases

cvcap alias [project] presents a picker, drilling through a list (or to start with perhaps just an item id)

Then cvcap add [item] [alias] puts the item in that destination rather than the default

add bookmark from clipboard

Adding a bookmark via the clipboard seems like a good compromise (don't force user to get toml right, but otoh also don't need to build a whole checkvist browser into the UI).

cvcap add-bookmark <bookmark-name> adds a bookmark from the clipboard (either a list or item URL) and names it bookmark-name

CVCap pulls any content off the clipboard, validates it, checks the existence of the bookmark, and if present on the server, writes it to the config file.

Implement top-level (list) sync in cvcap cli

Not sure if cli will ever use sync proper (which is mainly intended for future apps using cvapi lib)
But a useful slice as a POC would be:

on cvcap add task -l, read the lists from sqlite so they're instantly available.
Add a 'synclists' command to refresh the local list.
Not really a sync but just a list download-and-persist.

linux-musl binary faulty (build or link problem?)

Successfully builds with the github actions ubuntu runner. But the binary doesn't call any copypasta functions. I think there's a musl issue with the x11-clipboard dep (that copypasta has). Investigate.

Add day notes

something like cvcap day "note content", which:

  • adds an item if it doesn't already exist at [year]/month/day (soft scheme with template?)
  • adds a link to this in one's configured main note

Attach a file

ie. something like cvcap add task_content -f [filename]

Binaries would be nice

cvcap seems to be perfect for using Alfred on Mac to do quick entry on Checkvist, but would prefer not having to install Rust (as I don't know it).

Improve scripting UI

There are really 3 types of UIs for terminal use:

  1. the classic cli, with all necessary data supplied as flags, for one-shot interactionless use
  2. interactive, prompting the user linewise for missing info (eg. npm create ...)
  3. tui

cvcap currently is an awkward blend of cli/interactive - mostly interactive but sort-of cli with the -q flag. Currently however this mode just fails when info is missing (eg there's no defualt list), with no capacity to provide the missing data as part of the invocation.

The standard approach to dealing with cli vs interactive is to blend them, using an ever more complex combination of flags - eg -y to skip prompts. But which prompts? This could be sorted out with positional -ys or some other complex combination of flags.

But I wonder if it might be simpler (and less tied to posix/unix) to just keep the two cases separate.

-q (or maybe something like --noninteractive to make it triply clear) can flick cvcap into a different mode, where all data must be provided to avoid a nonzero exit. To make this even clearer, and avoid having to mess more than I want to with clap, my current thought is for that data to be provided en bloc in a structure. Inline JSON perhaps, or perhaps search for a way that needs less "-escaping (does this even matter for scripting/programmatic use?)

Move config to config-rs or figment

Then my interaction wrapper could be a config-rs or figment provider - ie. give it a config and an ordering, and it can layer its config over whatever we already have

Investigate possible sync designs

Future uses of the library (eg. add tasks while offline) depend on having a local cache of some sort. Perhaps just operational updates. Perhaps an actual sync'd store. Investigate.

Refactor add.rs

cf. the add-bookmark.rs pattern. Generally:

  • split functions that interact from those that don't
  • the former create data structures that the latter use
  • the type system validates

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.