Skip to content

Instantly share code, notes, and snippets.

@cahna
Created July 6, 2014 09:24
Show Gist options
  • Select an option

  • Save cahna/95d4a7cba13ee1fa898f to your computer and use it in GitHub Desktop.

Select an option

Save cahna/95d4a7cba13ee1fa898f to your computer and use it in GitHub Desktop.

Revisions

  1. cahna created this gist Jul 6, 2014.
    3 changes: 3 additions & 0 deletions ENV.moon
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    -- Package that helper into the worlds shortest module.
    -- Usage: import HOME, SHELL, EDITOR from require 'ENV'
    setmetatable {}, __index: (k) => os.getenv k
    7 changes: 7 additions & 0 deletions env_shorthand.moon
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    -- Nifty shorthand for creating local variables from environment variables in moonscript using metatables
    import HOME, SHELL, EDITOR from setmetatable {}, __index: (k) => os.getenv k

    -- are both equivalent to:
    HOME = os.getenv "HOME"
    SHELL = os.getenv "SHELL"
    EDITOR = os.getenv "EDITOR"
    1 change: 1 addition & 0 deletions example.moon
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    import HOME, SHELL, EDITOR from require 'ENV'