lervag/apy

Specify deck for add-from-file

Closed this issue ยท 4 comments

Hi!
I was looking for a way to specify a deck when using add-from-file. After some digging in the code I found that it was possible to add deck: deck-name to the notes section of a card. However, this seems cumbersome for my use-case. Would it make sense to add a deck option to the command line function?

I'm very new to anki, so maybe I have misunderstood something, but I've envisioned the following workflow:

  1. Accumulate my knowledge in my wiki(.vim).
  2. I have some files with "Q&A", with new paragraph for different sub-topics. E.g. the file vim_qa.wiki contains paragraphs where the first line is "registers" and one starting with "movement", followed by lines of Q:... and A:..., such that the cards generated from the registers paragraph are tagged registers.
  3. Use the vimscript from the wiki to generate a (temporary) markdown file (vim.md)
  4. Add the cards using add-from-file vim.md -d vim to the deck vim (where the -d-option is currently not supported)

Since I consider the markdown generated by the vimscripts to be temporary (I will delete this after I have added the cards, as my file with Q&A contains all the information in a more compact format), I would like to avoid editing the markdown. It would be great to be able to specify the deck in the command line, like envisioned in 4. above, to add all the notes from vim.md to the deck "vim". If desirable, I could probably attempt a PR at some point. For the scenario that deck is specified with both the markdown note and command line I'm fine with either one overriding the other (as I won't specify deck in markdown myself).

I suspect (hope?) that this workflow is similar to that of @lervag, but I'm very open for suggestions ๐Ÿ˜ƒ Thanks for all your contributions to the open source community! I'm a huge fan of wiki.vim and vimtex, and apy looks promising. Workflow screencasts welcome! ๐Ÿคฉ

Hi! I was looking for a way to specify a deck when using add-from-file. After some digging in the code I found that it was possible to add deck: deck-name to the notes section of a card. However, this seems cumbersome for my use-case. Would it make sense to add a deck option to the command line function?

I don't see any reason why we should not allow this option. So it's added now.

I'm very new to anki, so maybe I have misunderstood something, but I've envisioned the following workflow: โ€ฆ

Cool; thanks for sharing! You are right that this is close to my personal workflow. However, one difference is that I don't keep my list of Anki notes in my personal wiki. I use my index for building list of new questions similar to your workflow, but when I add them I delete the corresponding list in my index.

For me, my wiki and Anki are complementary. I sometimes add Anki cards to help me remember that I know something, and then if I need the info I remember to read my notes.

If desirable, I could probably attempt a PR at some point.

Too late, but I would not mind some help with the tool in general. If you have the time and interest, then I would be happy to help you on getting started. E.g., one task that seems quite easy but useful is to add type annotations where they are missing. :)

For the scenario that deck is specified with both the markdown note and command line I'm fine with either one overriding the other (as I won't specify deck in markdown myself).

I'll let what is written in the file override what is passed by cli options for now.

I suspect (hope?) that this workflow is similar to that of @lervag, but I'm very open for suggestions ๐Ÿ˜ƒ Thanks for all your contributions to the open source community! I'm a huge fan of wiki.vim and vimtex, and apy looks promising. Workflow screencasts welcome! ๐Ÿคฉ

Thank you for the kind words! I don't know how to do screencasts, unfortunately... don't even know where to start. :p

PS! Anki 23.10 was just released, so I'm also now working on updating apy for compatibility with it.

I've pushed a PR for upgrading to 23.10: #76. Ill close this issue as I believe it was already resolved.

thanks for this! ๐Ÿ˜ƒ

I've tested it now and it seems to work. One edge case that is not really an issue for me, but a bit counter intuitive: it seems that the duplication detection noes not consider deck. So if I first to: apy add-from-file somefile.md -d mydeck1 all the cards are added. However in a subsequent apy add-from-file somefile.md -d mydeck2 (same file/cards, different deck), all cards are detected as duplicates and are not added.

thanks for this! ๐Ÿ˜ƒ

My pleasure; thanks for suggesting improvements :)

it seems that the duplication detection noes not consider deck. So if I first to: apy add-from-file somefile.md -d mydeck1 all the cards are added. However in a subsequent apy add-from-file somefile.md -d mydeck2 (same file/cards, different deck), all cards are detected as duplicates and are not added.

Interesting. I'm not even sure if you are allowed to add duplicates across different decks, but if you are: why would you want to do that?