Shikensu
🚀
Create a Shikensu Program.
This is basically a wrapper around list that creates a Program
for you and initialises the needed permissions.
import Shikensu
import Shikensu.Contrib as Shikensu
import Shikensu.Focus exposing (Focus(..))
import Task
Shikensu.program sequence CurrentDirectory
sequence task =
task
|> Task.map (Shikensu.withExtension "md")
|> Task.andThen Shikensu.read
|> Task.map (Shikensu.renderContent markdownRenderer) -- See `example` folder
|> Task.andThen (Shikensu.write destinationFocus)
Provides a way to make and operate on multiple lists.
Technically not multiple programs, but same idea as
the program function, just with multiple lists.
import Shikensu
import Shikensu.Focus exposing (Focus(..))
Shikensu.programs
[ { focus = Relative (Path.directory [ "posts" ])
, sequence = Task.andThen Shikensu.read
}
, { focus = Relative (Path.directory [ "images" ])
, sequence = Task.map (\bundle -> ...)
}
]
Alias for a Node program.
The list function itself, unwrapped.
Recursively lists a directory and then gives you a Task
containing a Bundle which in turns has an array of Definitions
stored under the property named compendium.
This collection of Definitions is the main thing you'll be working with.
The goal of this library is to scan a file tree, manipulate it and then
optionally write it back to disk. This is done through these definitions.
import Shikensu
import Shikensu.Focus exposing (Focus(..))
Shikensu.list fsPermission CurrentDirectory
⚠️ The given Focus will always be in the context of
the environment of the resulting Gren binary that is being executed.
So for example, say your pwd command returns ~/code/shikensu/,
and your focus is Relative (Path.Directory [ "..", "example" ]).
If you run ./binary/app the resulting path will be ~/code/example/.
Alias for the main Task type we'll be working with here.
IO
Read the files in the given compendium/bundle,
setting the content property in the definition.
Write each definition to their respective location. The location will depend on the focus and the environment it was run in.