Skip to content
This repository has been archived by the owner on Dec 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from WebCu/feature/create-link-card-command
Browse files Browse the repository at this point in the history
Retrieve only the open boards. Update README file.
  • Loading branch information
WebCu authored Apr 29, 2020
2 parents b626099 + d2d5e48 commit 2063529
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 45 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.idea
.env
/.php_cs.cache
/notes.md
65 changes: 24 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,30 @@
The first thing was create the tag to easily navigate
between the different stages of the POC.
# TRELLO CLI
A CLI to handle repetitive tasks in Trello.

https://www.jetbrains.com/help/phpstorm/2020.1/use-tags-to-mark-specific-commits.html
## Installation
- After have cloned the repo. Go to the folder where the
project was clone and start the php container:

These are the default values of the Symfony Console
environment variables
#### Symfony Console
APP_ENV=dev
APP_DEBUG=1
`docker-compose up -d`

Add namespace and author to composer.json
"authors": [
{"name": "Jorge Gonzalez (Webcu)"}
],
- Go inside the container:

"autoload": {
"psr-4": {
"Trello\\CLI\\": "src/"
}
}
`docker-compose exec php bash`


https://symfony.com/doc/current/components/console/helpers/questionhelper.html#let-the-user-choose-from-a-list-of-answers

Add the composer.lock to the repo to avoid problems in
the future because of new versions of the library that
we use.

Deciding between single quotes or double quotes:
Like I used a lot of variable interpolation I prefer
use double quotes

Creation of services
Pass them to the command like arguments to be easily
Interchangeable.
- Install the dependencies:

HttpClient can have a wrapper?
Yes, query string parameters

Add phpcs
Install it
`composer require --dev friendsofphp/php-cs-fixer`
Use it
`php vendor/bin/php-cs-fixer fix src/`
or
`./vendor/bin/php-cs-fixer fix src/`
`composer install`

## Configuration
Make a copy of .env.dist and named it .env. Add to the
.env file your Trello's API and Toke. You can find information
about how to get that info in this guide:

## Working with the CLI
All this commands must be executed inside of the
container.

- Create a card with a checklist where the check items
are links extracted from a web page.

`php index.php trello-cli:create-link-card`
7 changes: 3 additions & 4 deletions src/Service/TrelloApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ public function __construct(HttpClientInterface $httpClient, string $key, string
"token" => $token,
];
}

// Todo Select the active boards only (Active != Archived)

public function getTrelloBoards(): array
{
$response = $this->httpClient->request(
"GET",
"https://api.trello.com/1/members/me/boards",
["query" => array_merge($this->defaultQuery, ['fields' => 'name'])]
["query" => array_merge($this->defaultQuery, ["fields" => "name", "filter" => "open"])]
);

return array_column($response->toArray(), null, "name");
Expand All @@ -35,7 +34,7 @@ public function getBoardLists(string $boardId): array
$response = $this->httpClient->request(
"GET",
"https://api.trello.com/1/boards/{$boardId}/lists",
["query" => array_merge($this->defaultQuery, ['fields' => 'name'])]
["query" => array_merge($this->defaultQuery, ["fields" => "name"])]
);

return array_column($response->toArray(), null, "name");
Expand Down

0 comments on commit 2063529

Please sign in to comment.