title: Command line interface for editor
body: <p>There's a lot of possibilities on how to create a <strong>CLI</strong> for an app, but I don't want to overcomplicate it.  </p>
  
  <p>I want to create a script to which I can pass an argument with file or directory and this script will be able to determine whether this file/directory exists and if so it'll open an app in it or if it doesn't it'll create it and then open and app.</p>
  
  <p>It's easy to check for existance of <em>the location</em> eg.</p>
  
  <pre><code>if [[ -d $PASSED ]]; then
      echo "$PASSED is a directory"
  elif [[ -f $PASSED ]]; then
      echo "$PASSED is a file"
  else
      echo "$PASSED is not valid"
      exit 1
  fi
  </code></pre>
  
  <p>but I have no idea how to solve the distinction between handling non existent thing eg. I can have a file or a directory, so <code>./coder no_such_file.txt</code> should create a file in current directory, but I can as well call it like <code>./coder directory/</code> and how to determine it? Is it possible to determine it <em>automatically</em> or do I have to parse it and check for <code>/</code>?</p>