The can-add command is used to add notes into the notebook from the writing folder.

It isn't possible to include cycles in can notes, so can-add should print a warning and exit if a cycle exists in the notes.

can-add should add all notes which are currently in the writing folder. This behaviour may be more granular in the future.

Internal links should be translated into addresses before being placed into the notebook, using the format ./note-name.<ext>, as if linking to the local file. If ./note-name.ext doesn't exist, can-add should check to see if the note by that name (excluding the extension) currently exists in the notebook, and should replace the name with the existing address. If the name doesn't exist and ther is no local file, can-add should complain and bail out of the operation.

To achieve this, can-add will have to build a graph of notes existing in the writing folder. Starting with any leaf-node, can-add will write the contents of the file to its address and add the name of the file as metadata. It will remove the leaf-node from it's internal graph and do the same for another leaf-node, until no notes remain.

If can-add would add a note with the same name as another note already in the notebook, it should be added as normal. The metadata of the old note should be updated to remove this name and references to the old note should be updated with a reference to the new note. This process will bloom out to all transitive dependencies. It's possible that a separate command will be built to handle each step of these updates. can-add should add this information to a log, to allow the process to be viewed or reversed later.

  • It isn't possible to build cycles in your notes
    • It isn't possible to use can to build your notes to link into a cycle in any way. The can status command should warn you if your working notes form a cycle, and can add will refuse to add notes which form a cycle.
  • can commands
    • | command | description | | can-status | report the current state of the writing folder | | can-add | add notes from the writing folder into the notebook | | can-new | create a new writing-folder containing a notebook | | can-ast-at | given an address, find the AST of a note | | can-md | convert from markdown to can's internal AST format | | can-address | find the address of a particular AST | | can-note-graph | construct a list of addressed notes from the writing folder |