As a user, I should be able to browse resources by issuing the `cd` command
ltackett opened this issue · comments
Lorin Tackett commented
This will work pretty much exactly like *nix.
cd
will manage a path array in localStorage. Some programs (such as ls
) will be path-aware.
Jotted down from my notes
# cd - sets `path`
# =============================================================================
cd: (newPath) ->
if localStorage.path
path = JSON.parse(localStorage.path)
else
path = []
# Going back one or multiple dirs
if newPath.indexOf('..') > -1
newPath.split('/').map (p) ->
if p == '..' then path.pop()
# Add new path to path array.
# We will need to do error checking on this
# to make sure the value of newPath exists.
else
path.push newPath
# Apply to localStorage
localStorage.setItem('path', newPath)