Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

2 лет назад
2 лет назад
2 лет назад
2 лет назад
2 лет назад
2 лет назад
2 лет назад
2 лет назад
2 лет назад
2 лет назад
2 лет назад
2 лет назад
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. ## How are Xhive Framework commands available via bench?
  2. bench utilizes `xhiveframework.utils.bench_manager` to get the framework's as well as those of any custom commands written in application installed in the Xhive environment. Currently, with *version 12* there are commands related to the scheduler, sites, translations and other utils in Xhive inherited by bench.
  3. ## Can I add CLI commands in my custom app and call them via bench?
  4. Along with the framework commands, Xhive's `bench_manager` module also searches for any commands in your custom applications. Thereby, bench communicates with the respective bench's Xhive which in turn checks for available commands in all of the applications.
  5. To make your custom command available to bench, just create a `commands` module under your parent module and write the command with a click wrapper and a variable commands which contains a list of click functions, which are your own commands. The directory structure may be visualized as:
  6. ```
  7. xhiveframework-bench
  8. |──apps
  9. |── xhiveframework
  10. ├── custom_app
  11. │   ├── README.md
  12. │   ├── custom_app
  13. │   │   ├── commands <------ commands module
  14. │   ├── license.txt
  15. │   ├── requirements.txt
  16. │   └── setup.py
  17. ```
  18. The commands module maybe a single file such as `commands.py` or a directory with an `__init__.py` file. For a custom application of name 'flags', example may be given as
  19. ```python
  20. # file_path: xhiveframework-bench/apps/flags/flags/commands.py
  21. import click
  22. @click.command('set-flags')
  23. @click.argument('state', type=click.Choice(['on', 'off']))
  24. def set_flags(state):
  25. from flags.utils import set_flags
  26. set_flags(state=state)
  27. commands = [
  28. set_flags
  29. ]
  30. ```
  31. and with context of the current bench, this command maybe executed simply as
  32. ```zsh
  33. ➜ bench set-flags
  34. Flags are set to state: 'on'
  35. ```