title: How do you write a javascript CLI without exiting node environment?
body: <p>I know it is possible to write a command line interface with node but all examples i have found so far is simply passing parameters in the terminal that will execute a node script and then immediately exit the node environment, loosing all its variables and state.</p>
  
  <p>For example if i have an api with a login function and another function which depend on the auth state i want to do everything inside node.</p>
  
  <p>I know this way works but there must be a better way that is more straight forward than writing require in the terminal every single time?</p>
  
  <pre><code>$. node
  $. let api = require('./myApi')
  
  $. api.login()
  $. api.fetchData()
  </code></pre>