Skip to content

Consider MODULE Directive to Implement Sub-Module Pattern #50

@TekWizely

Description

@TekWizely

Consider this Runfile

# justprep/test/Runfile

module_aaa := "modules/aaa.run"
module_bbb := "modules/bbb.run"

EXPORT module_aaa, module_bbb

##
# Say hi
hello:
  echo "Hello World"

##
# List all tasks including the modules
list_all:
  run list
  run aaa
  run bbb

##
# Module aaa
aaa:
  run -r ${module_aaa} ${@}

##
# Module bbb
bbb:
  run -r ${module_bbb} ${@}

and two others aaa.run and bbb.run both in a modules directory.

# .../modules/aaa.run

##
# Module aaa magic
magic:
  echo 'Do you believe in Magic?'

##
# Do something magical in aaa
xyzzy:
  echo "Magic from aaa ..."
  echo "... watch me pull a ${1} out of my hat."

... and ...

# .../modules/bbb.run

##
# Module bbb magic
magic:
  echo 'Do you believe in Magic?'

##
# Do something magical in bbb
xyzzy:
  echo "Magic from bbb ..."
  echo "... watch me pull a ${1} out of my hat."

Here is a console session using those three files:

13:51:20 3.1.2p20 support_run s5:test $ run
using runfile: /Users/dewayne/Documents/sandbox/git_repos/madbomber/justprep/working/support_run/test/Runfile

Commands:
  list        (builtin) List available commands
  help        (builtin) Show help for a command
  version     (builtin) Show run version
  hello       Say hi
  list_all    List all tasks including the modules
  aaa         Module aaa
  bbb         Module bbb

Usage:
       run <command> [option ...]
          (run <command>)
  or   run help <command>
          (show help for <command>)

see 'run --help' for more information
13:51:30 3.1.2p20 support_run s5:test $ run list_all
Commands:
  list        (builtin) List available commands
  help        (builtin) Show help for a command
  version     (builtin) Show run version
  hello       Say hi
  list_all    List all tasks including the modules
  aaa         Module aaa
  bbb         Module bbb
using runfile: /Users/dewayne/Documents/sandbox/git_repos/madbomber/justprep/working/support_run/test/modules/aaa.run

Commands:
  list       (builtin) List available commands
  help       (builtin) Show help for a command
  version    (builtin) Show run version
  magic      Module aaa magic
  xyzzy      Do something magical in aaa

Usage:
       run <command> [option ...]
          (run <command>)
  or   run help <command>
          (show help for <command>)

see 'run --help' for more information
using runfile: /Users/dewayne/Documents/sandbox/git_repos/madbomber/justprep/working/support_run/test/modules/bbb.run

Commands:
  list       (builtin) List available commands
  help       (builtin) Show help for a command
  version    (builtin) Show run version
  magic      Module bbb magic
  xyzzy      Do something magical in bbb

Usage:
       run <command> [option ...]
          (run <command>)
  or   run help <command>
          (show help for <command>)

see 'run --help' for more information
13:51:41 3.1.2p20 support_run s5:test $ run aaa
using runfile: /Users/dewayne/Documents/sandbox/git_repos/madbomber/justprep/working/support_run/test/modules/aaa.run

Commands:
  list       (builtin) List available commands
  help       (builtin) Show help for a command
  version    (builtin) Show run version
  magic      Module aaa magic
  xyzzy      Do something magical in aaa

Usage:
       run <command> [option ...]
          (run <command>)
  or   run help <command>
          (show help for <command>)

see 'run --help' for more information
13:51:45 3.1.2p20 support_run s5:test $ run bbb
using runfile: /Users/dewayne/Documents/sandbox/git_repos/madbomber/justprep/working/support_run/test/modules/bbb.run

Commands:
  list       (builtin) List available commands
  help       (builtin) Show help for a command
  version    (builtin) Show run version
  magic      Module bbb magic
  xyzzy      Do something magical in bbb

Usage:
       run <command> [option ...]
          (run <command>)
  or   run help <command>
          (show help for <command>)

see 'run --help' for more information
13:51:52 3.1.2p20 support_run s5:test $ run aaa magic
Do you believe in Magic?
13:51:58 3.1.2p20 support_run s5:test $ run bbb magic
Do you believe in Magic?
13:52:04 3.1.2p20 support_run s5:test $ run aaa xyzzy rabbit
Magic from aaa ...
... watch me pull a rabbit out of my hat.
13:52:14 3.1.2p20 support_run s5:test $ run bbb xyzzy dinosaur
Magic from bbb ...
... watch me pull a dinosaur out of my hat.
13:52:33 3.1.2p20 support_run s5:test $

What I do in justprep is to turn a line that looks like this ...

module aaa := "modules/aaa.run

into lines that look like this ...

module_aaa := "modules/aaa.run
EXPORT module_aaa

##
# Module aaa
aaa:
  run -r ${module_aaa} ${@}

Originally posted by @MadBomber in #47 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions