# create-mvc

## Purpose

The `create-mvc` command will create a new MVC triad and configure it at `Application.groovy`. It will also create a test case for its controller.

## Examples

    griffon create-mvc foo

## Description

MVC groups are the basis for Griffon's MVC implementation. Refer to the MVC Pattern Overview to know more about MVC groups and their features. Calling `griffon create-mvc foo` results in the following files being created

    griffon-app/controllers/FooController.groovy
    griffon-app/models/FooModel.groovy
    griffon-app/views/FooView.groovy
    test/integration/FooTests.groovy

`Application.groovy` will be updated with a new group definition

    mvcGroups {
        // MVC Group for "foo"
        'foo' {
            model      = 'foo.FooModel'
            view       = 'foo.FooView'
            controller = 'foo.FooController'
        }
        …
    }

Usage:

    griffon create-mvc [name]

Arguments:

- `name` - The name of the group to create.

Options:

- `archetype` - The name of an archetype. Defaults to default.
- `model` - The name of the model template. Defaults to Model.
- `view` - The name of the view template. Defaults to View.
- `controller` - The name of the controller template. Defaults to .Controller.
- `group` - The name of the common template prefix for Model, View and Controller. Can be overridden by individual members
- `integrationTests` - The name of the integration test template. Defaults to IntegrationTests.
- `file-type` - The file type of each artifact, i.e, groovy|java|etc
- `skip-model` - Skips generating a model member if set to true
- `skip-view` - Skips generating a view member if set to true
- `skip-controller` - Skips generating a controller member if set to true
- `with-model` - Sets the model member to the specified full qualified class name
- `with-view` - Sets the view member to the specified full qualified class name
- `with-controller` - Sets the controller member to the specified full qualified class name

More Examples:

    griffon create-mvc foo -group=Custom

Creates a new group definition where MVC member templates are assumed to be `CustomModel`, `CustomView` and `CustomController`. Will use the default template when there's no match.

    griffon create-mvc foo -view=Dialog

Creates a new group definition overriding the default template for the View only.

    griffon create-mvc foo -skip-controller=true

Creates a new group definition without a Controller. The configuration will look like this

    mvcGroups {
        // MVC Group for "foo"
        'foo' {
            model      = 'foo.FooModel'
            view       = 'foo.FooView'
        }
        …
    }

    griffon create-mvc foo -with-controller=foor.BarController

Creates a new group definition with another Controller class. The Controller is assumed to exist, a file will not be created for it. The configuration will look like this

bc. mvcGroups { // MVC Group for "foo" 'foo' { model = 'foo.FooModel' view = 'foo.FooView' controller = 'bar.BarController' } … }