daikokucli

![CLI architecture](architecture.png "Architecture") # Installation This project can be installed and compiled from source with this Cargo command: ``` $ cargo install daikokucli or $ brew tap maif/daikokucli $ brew install daikokucli ``` Additionally there are [precompiled artifacts built on CI][artifacts] which are available for download as well. [artifacts]: https://github.com/MAIF/daikoku/releases Installation can be confirmed with: ``` $ daikokucli version ``` Subcommands can be explored with: ``` $ daikokucli help ``` # Core commands Daikokucli uses your home folder to store the list of projects inside a `.daikoku` file. Each project created with the CLI should contain a `src` folder and a `.daikoku/.environments`. This file will contain You can start a new project ```sh daikokucli create --name= --path= ``` then add a default Daikoku environment ```sh daikokucli environments add --name= --server= ``` > The Daikoku server has to be reachable and will be checked before saving the configuration you can start to develop and watch file changes ```sh daikokucli watch ``` Common practices involve utilizing the directives within the Daikoku CMS to access private entities based on the connected user's permissions. You have the option to configure the token for accessing your CMS with an authenticated user by pasting the token from your Daikoku profile page. ```sh daikokucli login --token= ``` If you have many environments you can switch between us simply using ```sh daikokucli watch --environment= ``` or permanently by changing the default project or environment ```sh daikokucli environments default --name= daikokucli projects default --name= ``` you can view the currently used project and the others ```sh daikokucli projects list ``` At anytime, you can track an existing CMS folder or update its information ```sh daikokucli projects add --name= --path= --overwrite= ``` Once ready, you can synchronize your sources with the Daikoku environment ```sh daikokucli sync ``` ## Start a new project by importing an existing one If you already have a legacy CMS on your Daikoku, you can start by importing it ```sh daikokucli projects import --name= \ --path= \ --server= \ --token= ``` # Manage your assets You can manage your images, diagrams, or any type of files directly by creating a `/assets` folder inside your CMS project. Each asset is save in the S3 of your Daikoku using the following command ```sh daikokucli assets add --filename= \ --path= \ --desc= \ --title= --slug= ``` If you require a particular `slug` for your asset, you have the option to replace the automatically generated one by specifying the `slug` field. Additionally, you can exclude the `path` field, which is only necessary when creating an asset from a subfolder within the `assets` directory. To delete your asset you have to give the `filename` and the `slug` iif it differs ```sh daikokucli assets remove --slug= --filename= ``` As others commands, you can display all registered assets ```sh daikokucli assets list ``` If you prefer to synchronize all assets with a single command, it offers speed advantages over doing so individually, albeit with reduced configurability. ```sh daikokucli assets sync ``` # Authorized applications Just before running the `daikoku login` command, you have to configure your tenant by adding the CLI server. By default, the server is set to `http://localhost:3334` but you can overwrite it using the `WATCHING_PORT` environment variable. ```sh daikokucli login ``` # CMS Directives ## daikoku-user `parameters`: - string user id ```html {{#daikoku-user "{{userId}}"}}
{{user.name}}
{{/daikoku-user}} ``` ## daikoku-owned-apis `parameters` - visibility: can be Private | Public | All ```html {{#daikoku-owned-apis visibility="Private"}} Mon api : {{api.name}} {{/daikoku-owned-apis}} ``` ## daikoku-owned-api `parameters`: - String API id - The API version is optional, but it defaults to 1.0.0 when not specified. ```html {{#daikoku-owned-api "{{apiId}}" version="1.0.0"}} Mon api : {{api.name}} {{/daikoku-owned-api}} ``` ## daikoku-json-owned-apis `parameters`: - Visibility : Private, Public or All ```html {{#daikoku-json-owned-apis visibility="Private"}} {{/daikoku-json-owned-apis}} ``` ## daikoku-json-owned-api `parameters`: - The API id, string value expected - The API version is optional, but it defaults to 1.0.0 when not specified. ```html {{#daikoku-json-owned-api "{{apiId}}" version="1.0.0"}} {{/daikoku-json-owned-api}} ``` ## daikoku-owned-teams ```html {{#daikoku-owned-teams}} Ma team : {{team.name}} {{/daikoku-owned-teams}} ``` ## daikoku-owned-team `parameters`: - The team ID, string value expected" ```html {{#daikoku-owned-team "{{teamId}}"}} Mon team : {{team.name}} {{/daikoku-owned-team}} ``` ## daikoku-json-owned-teams ```html {{daikoku-json-owned-teams}} ``` ## daikoku-json-owned-team `parameters`: - The Team ID, String value expected ```html {{#daikoku-json-owned-team "{{teamId}}"}} {{/daikoku-json-owned-team}} ``` ## tenant ```html {{tenant.name}} - {{tenant.style.description}} ``` ## is_admin ```html {{is_admin}} ``` ## connected ```html {{connected}} ``` ## user When you have an user returned from directive, you can use the following fields - `name` - `email` - `_id` - `_humandReadableId` - `picture` - `isDaikokuAdmin` - `starredApis` ```html
{{user.name}} - {{user.email}}
``` ## request ```html
{{request.path}} - {{request.method}} - {{request.headers}}
``` ## daikoku-css ```html
{{daikoku-css}}
``` ## for `parameters`: - the fieldname used in the helper content ``` {{#for '{{team.users}}' field='myuser' }} {{myuser.userId}} {{/for}} ``` ## size ```html {{size '{{team.users}}'}} ``` ## ifeq ```html {{#ifeq "{{plan.type}}" "FreeWithoutQuotas"}} You'll pay nothing and do whatever you want {{/ifeq}} ``` ## ifnoteq ```html {{#ifnoteq "{{plan.type}}" "FreeWithoutQuotas"}} You'll pay nothing and do whatever you want {{/ifnoteq}} ``` ## getOrElse ```html {{getOrElse "{{plan.customName}}" "Un plan"}} ``` ## translate ```html {{translate 'Logout'}} ``` ## daikoku-path-param `parameters`: - the position of the path params ```html {{daikoku-path-param '0'}} ``` ## daikoku-query-param `parameters`: - the name of the query param ```html {{daikoku-query-param 'my-query-param'}} ``` ## daikoku-template-wrapper `parameters`: - Block path - List of key=value usable in content ```html {{#daikoku-template-wrapper '' ="" }} {{/daikoku-template-wrapper}}" ``` ## daikoku-apis ```html {{#daikoku-apis}} Api : {{api.name}} {{/daikoku-apis}} ``` ## daikoku-api `parameters`: - API id, String value expected ```html {{#daikoku-api "{{apiId}}" version="1.0.0"}} Mon api : {{api.name}} {{/daikoku-api}}" ``` ## daikoku-json-apis ```html {{daikoku-json-apis}} ``` ## daikoku-json-api `parameters`: - API Id, String value expected ```html {{#daikoku-json-api "{{apiId}}" version="1.0.0"}} {{/daikoku-json-api}} ``` ## daikoku-teams ```html {{#daikoku-teams}} Team : {{team.name}} {{/daikoku-teams}} ``` ## daikoku-team `parameters`: - Team Id, String value expected ```html {{#daikoku-team "{{}}"}} My team : {{team.name}} {{/daikoku-team}} ``` ## daikoku-json-teams ```html {{daikoku-json-teams}} ``` ## daikoku-json-team `parameters`: - Team Id, String value expected ```html {{#daikoku-json-team "{{}}"}} {{/daikoku-json-team}} ``` ## daikoku-documentations `parameters`: - API id, String value expected ```html {{#daikoku-documentations "{{}}"}} {{documentation.title}} {{/daikoku-documentations}} ``` ## daikoku-documentations-page `parameters`: - API ID, String value expected - Page ID as String value ```html {{#daikoku-documentations-page "" page=""}} {{documentation.content}} {{/daikoku-documentations-page}} ``` ## daikoku-documentations-page-id `parameters`: - Team ID, String value expected - The named page parameter corresponding to the id of the expected page ```html {{#daikoku-documentations-page-id "" page=""}} {{content}} {{/daikoku-documentations-page-id}}" ``` ## daikoku-plans `parameters`: - API ID ```html {{#daikoku-plans ""}} {{plan.type}} {{/daikoku-plans}} ``` # License This project is licensed under the Apache 2.0 license with the LLVM exception. ### Contribution Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.