Este tópico descreve os comandos comuns da Function Compute Command Line Interface (fcli).
Pré-requisitos
Na pasta do arquivo executável, execute o comando fcli shell para entrar no modo interativo.
Alternar diretórios (cd)
O comando cd alterna os diretórios das entidades no Function Compute, e não os diretórios locais.
>>> cd serviceName //Goes to the directory of the serviceName service.
>>> ls //Lists the names of all functions under the serviceName service in the service directory.
>>> cd functionName //Goes to the directory of the functionName function.
>>> ls //Lists the names of all triggers under the functionName function in the function directory.
Listar arquivos no diretório atual (ls)
-l int32ou--limit int32: define o número máximo de recursos a listar. O valor padrão é 100.-t stringou--next-token string: lista os recursos a partir do NextToken.-p stringou--prefix string: exibe apenas os recursos com o prefixo especificado.-k stringou--start-key string: inicia a listagem a partir do recurso atual.
>>> cd myService
>>> ls
aFunction
bFunction
cFunction
cFuncion2
dFunction
eFunction
>>> ls -l 4 //Specifies the maximum number of files that are displayed to 4.
aFunction
bFunction
cFunction
cFuncion2
NextToken: dFunction
>>> ls -t dFunction //Lists files starting from NextToken (dFunction).
dFunction
eFunction
>>> ls -p c //Lists files whose names are prefixed with c.
cFunction
cFunction2
>>> ls -k dFunction //Lists files whose names start with dFunction.
dFunction
eFunction
Visualize o diretório da função (pwd)
Use o comando pwd para consultar o diretório da função.
Visualize detalhes do recurso (info)
O comando info consulta detalhes de um recurso do Function Compute, como nome do serviço, da função e do gatilho.
>>> info <your serviceName> //Queries the details of a service.
>>> info <your functionName> //Queries the details of a function.
>>> info <your triggerName> //Queries the details of a trigger.
Configure o fcli (config)
Use o comando config para modifique configurações no arquivo config.yaml.
>>> config --access-key-id 12345678 //Changes access-key-id to 12345678.
Exclua recursos (rm)
-
O comando
rmremove um recurso.NotaAntes de executar este comando, verifique se a função de destino não possui gatilhos ou se o serviço de destino não possui funções.
Para forçar a exclusão de um recurso, use
-fou--forced.
>>> rm myFunction
Do you want to remove the resource /fc/myService/myFunction [y/n]: //Needs to confirm the deletion operation before deleting the resource.
>>> rm -f myFunction //Not needs to confirm the deletion operation before deleting the resource.
Sandbox (sbox)
O fcli oferece um ambiente de sandbox local compatível com o ambiente de execução de funções do Function Compute. Nesse ambiente, você pode instale bibliotecas de dependência de terceiros para depuração local, entre outras operações.
-d stringou--code-dir string: especifica o diretório do código. Esse diretório é montado em /code no ambiente de sandbox.-t stringou--runtime string: define o ambiente de execução.
>>> sbox -d code -t nodejs6 //Installs Node.js 6 dependencies in the code directory.
Entering the container. Your code is in the /code direcotry.
root@df9fc****:/code# npm init -f //Generates package.json for Node.js 6 dependencies.
npm info it worked if it ends with ok
npm info using npm@3.10.10
npm info using node@v6.10.3
npm WARN using --force I sure hope you know what you are doing.
Wrote to /code/package.json:
{
"name": "code",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"jimp": "^0.2.28"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
npm info init written successfully
npm info ok
root@df9fc****:/code# npm install jimp //Installs jimp dependencies.
npm info it worked if it ends with ok
...
npm info lifecycle jimp@0.2.28~postinstall: jimp@0.2.28
code@1.0.0 /code
-- jimp@0.2.28
npm WARN code@1.0.0 No description
npm WARN code@1.0.0 No repository field.
npm info ok
root@df9fc****:/code# exit //Exits the sandbox environment.
help
O comando help exibe informações de ajuda.
help: lista todos os comandos disponíveis.-
[command] --help: mostra todos os parâmetros do comando atual.Por exemplo,
ls --help.
clear
Limpe a tela com o comando clear.
Sair do fcli (exit)
Saia do fcli com o comando exit.