Sometime programmer.
Jack of more than a few trades. Master of less than one.
A minimal commandline capture tool for Checkvist
License: MIT License
Sometime programmer.
Jack of more than a few trades. Master of less than one.
cvcap -c
(to default list)
cvcap -cl
(pick list)
Text-only still for now
To help the checkvist folk out if there are any problems, rate-limits overstepped, etc.
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.
ie. something like cvcap add task_content -f [filename]
ie. cvcap takes a checkvist item from the clipboard (one just added, or retrieved), and do something with it (open email, obsidian note, anki card, etc)
or https://discuss.checkvist.com/t/copyable-notes-with-hyperlinks/845/2
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
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.
cf. the add-bookmark.rs
pattern. Generally:
There are really 3 types of UIs for terminal use:
npm create ...
)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 -y
s 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?)
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
ie. no user interaction required, minimal informative output, and double check correct use of exit codes & stdin/out
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.
eg. cvcap add 'task' -l -q
shouldn't parse.
I think a guard on -q
?
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.
eg.
cvcap -v
[2022-07-05T09:11:19Z ERROR cvcap] is arg_required_else_help not set?
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.
This is because Config::new now tries interactive login if -q
isn't passed.
See integration_tests::logout_subcommand_when_not_logged_in_succeeds_with_message()
(commented out) for what should happen
https://github.com/RazrFalcon/pico-args
I often baulk at adding new features because finding a way to shoehorn the ux via clap is so intimidating. What should be one of the easiest parts of creating a Rust cli app is by far the hardest with clap.
ie. as a result of #18
At a minimum we'll need to add --workspace
to the cargo build & test.
This looks promising: https://github.com/marketplace/actions/build-rust-projects-with-cross
ie. cvcap "task" [other optional args]
should do the same as cvcap add "task" [other optional args]
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
ie. when the code between .start()
and .stop()
errors, the 'bye' message is still printed (mistakenly).
Not sure quite how this will be used in the cli yet (see #21 ). Primary use case is for a different checkvist-based app
Needs research
I've always been unhappy with clap. This might be a good alternative. Great docs, principled api.
& get cvcap -h
to display the add
args (-c -l
)
Of course I forgot that pipelines rely on output.
Relatedly, what should be cvcap's output? Currently there's none other than user messages
Easily anticipated so should be specifically handled.
ie. cat file | cvcap
error if text arg is also supplied cat file | cvcap 'spurious'
something like cvcap day "note content"
, which:
ie. within a list, as do bookmarks
Allows user to pick, but ignores and uses the default
[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.
Current method of providing a default add
subcommand isn't great. There seems to be a blessed method:
clap-rs/clap#4134
Also I'd like to not have to pass the main command's -q
value down into the subcommand via the Config
object
see pacak/bpaf#165
https://github.com/marketplace/actions/rust-release-binary
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.