Shikensu

🚀

program : (Task -> Task) -> Focus -> Program

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)
programs : Array { focus : Focus, sequence : Task -> Task } -> Program

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 -> ...)
      }
    ]
type alias Program = Program {} {}

Alias for a Node program.

list : Permission -> Focus -> Task

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/.

type alias Task = Task Error Bundle

Alias for the main Task type we'll be working with here.

IO

read : Bundle -> Task

Read the files in the given compendium/bundle, setting the content property in the definition.

write : Focus -> Bundle -> Task

Write each definition to their respective location. The location will depend on the focus and the environment it was run in.