Skip to content
Jon Crain edited this page Sep 16, 2020 · 1 revision

please make:module is a script that will take you through a wizard like setup of creating a module. This article will walk through the options available.

Module Location

Creating a module is cool!

 Where do you want to generate the module? [/path_to_munkireport/local/modules/]:
  [0] /path_to_munkireport/local/modules/
  [1] /path_to_munkireport/vendor/munkireport/

The default path is /path_to_munkireport/local/modules/ which is now also included by default in module_search_paths. You can also specify the full path at the prompt, or simply hit enter for the default or select 0 or 1 for the options.

Module Name

 What is the name of the module? [I ❤️ MunkiReport]:
 >

Next, name the module. Use the proper casing that you want to see in the end module. (and yes you can use emoji's)

Database Fields

How many database fields do you need? (apart from id and serial_number) [3]:
 >

This is where it may get tricky and planning comes into play. How many fields do you need. 3 is the default, but you can create as many as you want. It will then loop the following questions for the number of fields you select.

Field Questions

 What is the (short) English description of field 1? [Field 1]:
 >

 What is the name of field 1? [field_1]:
 >

 What is the type of field 1? [string]:
  [0] string
  [1] integer
  [2] bigInteger
  [3] boolean
  [4] text
 >

 Create index for field 1? [yes]:
  [0] yes
  [1] no
 >

 Create widget for field 1? [scrollbox]:
  [0] scrollbox
  [1] bargraph
  [2] no
 >

+---------+--------+-------+---------------------+---------+-----------+
| column  | type   | index | i18n                | en      | widget    |
+---------+--------+-------+---------------------+---------+-----------+
| field_1 | string | yes   | test.column.field_1 | Field 1 | scrollbox |
+---------+--------+-------+---------------------+---------+-----------+

...

 Do you need to store more than one row per machine? [no]:
  [0] yes
  [1] no
 >

Proposed database layout:
+---------------+------------+---------+---------------+
| Column        | Type       | Indexed | English       |
+---------------+------------+---------+---------------+
| id            | increments |         |               |
| serial_number | string     | unique  | Serial Number |
| field_1       | string     | yes     | Field 1       |
| field_2       | integer    | no      | Field 2       |
| field_3       | boolean    | no      | Field 3       |
+---------------+------------+---------+---------------+

 Do you wish to continue? (yes/no) [yes]:
 >

Your module is ready! It's available here:

/path_to_munkireport/local/modules/test/

Different field types will have different options to automatically create widgets.

Clone this wiki locally