How to use the jrnl.Journal.open_journal function in jrnl

To help you get started, we’ve selected a few jrnl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jrnl-org / jrnl / jrnl / cli.py View on Github external
raw = util.get_text_from_editor(config, template)
        else:
            try:
                print("[Compose Entry; " + _exit_multiline_code + " to finish writing]\n", file=sys.stderr)
                raw = sys.stdin.read()
            except KeyboardInterrupt:
                print("[Entry NOT saved to journal.]", file=sys.stderr)
                sys.exit(0)
        if raw:
            args.text = [raw]
        else:
            sys.exit()

    # This is where we finally open the journal!
    try:
        journal = open_journal(journal_name, config)
    except KeyboardInterrupt:
        print(f"[Interrupted while opening journal]", file=sys.stderr)
        sys.exit(1)

    # Import mode
    if mode_import:
        plugins.get_importer(args.import_).import_(journal, args.input)

    # Writing mode
    elif mode_compose:
        raw = " ".join(args.text).strip()
        log.debug('Appending raw line "%s" to journal "%s"', raw, journal_name)
        journal.new_entry(raw)
        print(f"[Entry added to {journal_name} journal]", file=sys.stderr)
        journal.write()