insanum / sncli

Simplenote CLI
MIT License
396 stars 34 forks source link

Can't create new notes #59

Closed trincadour closed 6 years ago

trincadour commented 6 years ago

Problem: I can't make new entries neither with sncli create or with the console GUI when pressing 'C'. In the GUI I get only a screen refresh when I try creating a note or even when I am trying to edit one.

Other functions like sncli list, sncli sync and sncli export are working fine, and I can see my notes as well.

Environment:

Error:

~$ sncli -t Title create "Something"
~$ sncli create Test

No error in both, only the usage text. Is that the correct way to make a note through stdin?

~$ sncli edit <a key listed by sncli list>

No error as well.

~$ sncli create

Traceback (most recent call last):
  File "/usr/local/bin/sncli", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.5/dist-packages/simplenote_cli/sncli.py", line 1371, in main
    sn.cli_note_create(False, title)
  File "/usr/local/lib/python3.5/dist-packages/simplenote_cli/sncli.py", line 1105, in cli_note_create
    content = self.exec_cmd_on_note(None)
  File "/usr/local/lib/python3.5/dist-packages/simplenote_cli/sncli.py", line 99, in exec_cmd_on_note
    'line': self.gui_body_get().focus_position + 1,
  File "/usr/local/lib/python3.5/dist-packages/simplenote_cli/sncli.py", line 219, in gui_body_get
    return self.master_frame.contents['body'][0]
AttributeError: 'sncli' object has no attribute 'master_frame'

When I am invoking sncli from emacs I get the same error.

(defun sncli-forward-buffer ()
  "Sends the current buffer as stdin to sncli and making a new entry in simplenote." 
  (interactive)
  (shell-command-on-region (point-min) (point-max) "sncli create ")
  (message "Buffer saved in  simplenote."))
Traceback (most recent call last):
  File "/usr/local/bin/sncli", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.5/dist-packages/simplenote_cli/sncli.py", line 1371, in main
    sn.cli_note_create(False, title)
  File "/usr/local/lib/python3.5/dist-packages/simplenote_cli/sncli.py", line 1105, in cli_note_create
    content = self.exec_cmd_on_note(None)
  File "/usr/local/lib/python3.5/dist-packages/simplenote_cli/sncli.py", line 99, in exec_cmd_on_note
    'line': self.gui_body_get().focus_position + 1,
  File "/usr/local/lib/python3.5/dist-packages/simplenote_cli/sncli.py", line 219, in gui_body_get
    return self.master_frame.contents['body'][0]
AttributeError: 'sncli' object has no attribute 'master_frame'

Am I missing something in my config file? I only have my username and password in it. Or maybe something is outdated?

trincadour commented 6 years ago

Solved

I have just found what was wrong. In the GUI case the problem was my $EDITOR variable, which I changed a few days ago to nothing (' ') and forgot to change back, so it was calling nothing and thus only refreshing the console. I specified it on the config file and now it's working normally.

As for the CLI command I simply was using it wrong, I didn't expect to use literally "-" as a command argument instead of changing to my custom text argument. So I just piped from echo to it like this:

echo "Testing" | sncli -t Test create -

And I got my note.

I think it would be good to specify a little more about sncli create in the readme, I only made the connection when looking the info about the import command. It's kinda confusing for beginners.

Sorry for the inconvenience.

samuelallan72 commented 6 years ago

@trincadour no inconvenience at all! Thanks for the heads up. 👍 I'll look into improving the readme/manual sometime.