Skip to content

Commit f09f92a

Browse files
committed
chore: deprecate cli methods
1 parent 211e3b8 commit f09f92a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

templates/cli/lib/commands/command.js.twig

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const {{ service.name | caseLower }} = new Command("{{ service.name | caseLower
5959
/**
6060
* @param {{ "{" }}{{ service.name | caseUcfirst }}{{ method.name | caseUcfirst }}RequestParams{{ "}" }} params
6161
*/
62-
{%~ block decleration -%}
62+
{% block decleration %}
6363
const {{ service.name | caseLower }}{{ method.name | caseUcfirst }} = async ({
6464
{%- for parameter in method.parameters.all -%}
6565
{{ parameter.name | caseCamel | escapeKeyword }},
@@ -72,7 +72,9 @@ const {{ service.name | caseLower }}{{ method.name | caseUcfirst }} = async ({
7272
{%- if method.type == 'location' -%}, destination{%- endif -%}
7373
{% if hasConsolePreview(method.name,service.name) %}, console{%- endif -%}
7474
}) => {
75-
{%~ endblock %}
75+
{% if method.deprecated %}
76+
console.warn('Warning: This command is deprecated.{% if method.replaceWith %} Please use "{{ method.replaceWith | replace({'.': ' '}) }}" instead.{% endif %}');
77+
{% endif %}
7678
let client = !sdk ? await {% if service.name == "projects" %}sdkForConsole(){% else %}sdkForProject(){% endif %} :
7779
sdk;
7880
let apiPath = '{{ method.path }}'{% for parameter in method.parameters.path %}.replace('{{ '{' }}{{ parameter.name | caseCamel }}{{ '}' }}', {{ parameter.name | caseCamel | escapeKeyword }}){% endfor %};
@@ -82,13 +84,14 @@ const {{ service.name | caseLower }}{{ method.name | caseUcfirst }} = async ({
8284
{{ include('cli/base/requests/api.twig') }}
8385
{% endif %}
8486
}
87+
{% endblock %}
8588

8689
{% endfor %}
8790
{% for method in service.methods %}
8891
{{service.name | caseLower }}
8992
.command(`{{ method.name | caseKebab }}`)
9093
{% autoescape false %}
91-
.description(`{{ method.description | replace({'`':'\''}) | replace({'\n':' '}) | replace({'\n \n':' '}) }}`)
94+
.description(`{% if method.deprecated %}[DEPRECATED] This command is deprecated.{% if method.replaceWith %} Please use '{{ method.replaceWith | replace({'.': ' '}) }}' instead.{% endif %} {% endif %}{{ method.description | replace({'`':'\''}) | replace({'\n':' '}) | replace({'\n \n':' '}) }}`)
9295
{% for parameter in method.parameters.all %}
9396
.{% if parameter.required and not parameter.nullable %}requiredOption{% else %}option{% endif %}(`--{{ parameter.name | escapeKeyword | caseKebab }}{% if parameter | typeName == 'boolean' %} [value]{% else %} {% if parameter.array.type|length > 0 %}[{% else %}<{% endif %}{{ parameter.name | escapeKeyword | caseKebab }}{% if parameter.array.type|length > 0 %}...{% endif %}{% if parameter.array.type|length > 0 %}]{% else %}>{% endif %}{% endif %}`, `{{ parameter.description | replace({'`':'\''}) | replace({'\n':' '}) | replace({'\n \n':' '}) }}`{% if parameter | typeName == 'boolean' %}, (value) => value === undefined ? true : parseBool(value){% elseif parameter | typeName == 'number' %}, parseInteger{% endif %})
9497
{% endfor %}

0 commit comments

Comments
 (0)