| 469 | } |
| 470 | |
| 471 | func getConverterCommand() cli.Command { |
| 472 | return cli.Command{ |
| 473 | Name: "converter", |
| 474 | Usage: "Generates code used by golang extensions", |
| 475 | Description: `gohan converter [path to file with schemas] [flags...] |
| 476 | |
| 477 | Converter generates code from yaml schemas. |
| 478 | Generated code: |
| 479 | * Definition of structs representing objects from each schema |
| 480 | * Interfaces for getters and setters for these objects |
| 481 | * Implementation of these interfaces by pointers to generated structs |
| 482 | * Interfaces that can be extended |
| 483 | * Constructors for objects with default values |
| 484 | * Database functions for generated structs (fetch, list) |
| 485 | * Schema ids |
| 486 | ARGUMENTS: |
| 487 | There is one argument - path to file with yaml schemas |
| 488 | `, |
| 489 | Flags: []cli.Flag{ |
| 490 | cli.StringFlag{Name: "goext-package", Value: "goext", Usage: "Package name for golang extension interfaces"}, |
| 491 | cli.StringFlag{Name: "crud-package", Value: "goodies", Usage: "Package name for crud functions"}, |
| 492 | cli.StringFlag{Name: "raw-package", Value: "resources", Usage: "Package name for raw structs"}, |
| 493 | cli.StringFlag{Name: "interface-package", Value: "interfaces", Usage: "Package name for interfaces"}, |
| 494 | cli.StringFlag{Name: "schema-package", Value: "schemas", Usage: "Package name for schema ids"}, |
| 495 | cli.StringFlag{Name: "output, o", Value: "", Usage: "Prefix add to output files"}, |
| 496 | cli.StringFlag{Name: "raw-suffix", Value: "", Usage: "Suffix added to raw struct names"}, |
| 497 | cli.StringFlag{Name: "interface-suffix", Value: "gen", Usage: "Suffix added to generated interface names"}, |
| 498 | }, |
| 499 | Action: func(c *cli.Context) { |
| 500 | if err := app.Run(app.ConverterParams{ |
| 501 | Config: c.Args().First(), |
| 502 | Output: c.String("output"), |
| 503 | GoextPackage: c.String("goext-package"), |
| 504 | GoodiesPackage: c.String("crud-package"), |
| 505 | ResourcePackage: c.String("raw-package"), |
| 506 | InterfacePackage: c.String("interface-package"), |
| 507 | SchemasPackage: c.String("schema-package"), |
| 508 | RawSuffix: c.String("raw-suffix"), |
| 509 | InterfaceSuffix: c.String("interface-suffix"), |
| 510 | }); err != nil { |
| 511 | fmt.Printf("%+v\n", err) |
| 512 | os.Exit(1) |
| 513 | } |
| 514 | }, |
| 515 | } |
| 516 | } |
| 517 | |
| 518 | func getRunCommand() cli.Command { |
| 519 | return cli.Command{ |