Fig Docs
  • 🏠Welcome to Fig
  • 👋Get Started
    • Download and Install
    • `fig home`
      • My Apps
      • The Sidebar
      • Settings
    • The Fig App Store
    • Hotkeys
  • 💪Autocomplete
  • 😀The Fig CLI
    • 1. Fig Overrides
    • 2. Fig Aliases
    • 3. $FIGPATH
    • 4. Fig Apps
  • 📖Interactive Runbooks
    • Form Elements
      • Input
      • Textarea
      • Dropdown
      • Checkboxes
      • Buttons
    • Templating & Interpolation
    • Scripting Language (Psilo)
      • Full List of Functions
    • Running Runbooks
    • Full Examples
  • ⚒️ Build your own CLI
    • `fig build`
    • .fig Files
  • 🧰Build your own App
    • Get Started
    • App Lifecycle
    • Key Concepts
      • Running Shell Commands
      • Reading Environment Variables
      • Accessing Files & Saving Data
      • Loading Local Resources
    • Window Managment
      • Setting Window Properties
      • Repositioning the Window
      • Focusing & Blurring the Window
    • Advanced
      • Creating a Pseudo-Terminal Session
  • Other
    • Fig for Teams
    • Security & Privacy
    • FAQ
    • Contact Us
  • Interactive Runbooks
Powered by GitBook
On this page
  1. Build your own App

App Lifecycle

Initialization

fig.init is the entry point for your app. fig.init is called once the fig.js runtime has loaded and configured the environment. Attempting to run fig commands before fig.init has been called will result in undefined behavior.

$ echo "Hello, world."| fig your-app parameter --flag value

fig.init = (stdin, options) => {
    console.log(stdin)   // "Hello, world"
    console.log(options) // ["parameter", "--flag", "value"]
}

In this case, stdin would be "Hello, world.". and options will be a list of the CLI flags. If your app is called with nothing piped in, stdin will be an empty string.

fig.init provides your app with any data from stdin that is passed to it as well as any flags/options, it is called with. The array of options can also be accessed with fig.options.

PreviousGet StartedNextKey Concepts

Last updated 4 years ago

🧰