Which command syntax is more intuitive?

Discussion in 'Mac Programming' started by 556fmjoe, May 3, 2014.

  1. 556fmjoe macrumors 65816

    Joined:
    Apr 19, 2014
    #1
    I'm writing a shell script that will use OpenSSL's SMIME function to encrypt a file. I'll need a way for the user to pass in the key. Let me know which of these options you think is easier to remember. The script is simply called "aes"

    Encrypting "file.txt" with "publickey.pem".
    Code:
    aes -e file.txt publickey.pem 
    vs
    Code:
    aes -e publickey.pem file.txt
    Decrypting the resulting encrypted file using "privatekey.pem"

    Code:
    aes -d file.txt.aes192 privatekey.pem
    vs
    Code:
    aes -d privatekey.pem file.txt.aes192
    Right now, this is for my own uses, so syntax doesn't really matter as long as I remember it. However, I might send it to some friends, so I would like it to be easy to use. I'm also planning to add a "-shred" option to shred the plaintext file, so that will have to make its way in there too.
     
  2. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #2
    I prefer named arguments to positional arguments.

    So I would instead have a syntax that looks like

    -k key
    -f file

    With them coming in either order.
     
  3. superscape macrumors 6502a

    superscape

    Joined:
    Feb 12, 2008
    Location:
    East Riding of Yorkshire, UK
    #3
    I agree with ArtOfWarfare, but out of the options you've given, I prefer the second option in both examples.
     

Share This Page