Skip to content

Commit

Permalink
feat(trello-cli): Add support for due date when publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
mheap committed Nov 24, 2023
1 parent c6ae218 commit 7b7415c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/bright-dolls-hear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@trello-cli/cli": patch
---

Allow setting due date when creating a card
1 change: 1 addition & 0 deletions packages/trello-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@trello-cli/cache": "workspace:*",
"@trello-cli/config": "workspace:*",
"chai": "^4.3.6",
"chrono-node": "^2.7.3",
"json2csv": "^5.0.7",
"trello.js": "^1.2.4"
},
Expand Down
9 changes: 8 additions & 1 deletion packages/trello-cli/src/commands/card/create.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { BaseCommand } from "../../BaseCommand";
import { Flags } from "@oclif/core";
import * as chrono from "chrono-node";

export default class Create extends BaseCommand<typeof Create> {
static description = "Create a card";
Expand All @@ -10,10 +11,10 @@ export default class Create extends BaseCommand<typeof Create> {
list: Flags.string({ required: true }),
position: Flags.enum({ options: ["top", "bottom"], default: "bottom" }),
label: Flags.string({ multiple: true }),
due: Flags.string(),
};

async run(): Promise<void> {

this.flags.label = this.flags.label || [];

// Convert label name to ID
Expand All @@ -23,9 +24,15 @@ export default class Create extends BaseCommand<typeof Create> {
}) as any
);

let dueDate = null;
if (this.flags.due) {
dueDate = chrono.parseDate(this.flags.due).toString();
}

const card = await this.client.cards.createCard({
idList: this.lookups.list,
name: this.flags.name,
due: dueDate!,
pos: this.flags.position as "top" | "bottom",
idLabels,
});
Expand Down
3 changes: 2 additions & 1 deletion packages/trello-cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"outDir": "dist",
"rootDir": "src",
"strict": true,
"target": "es2019"
"target": "es2019",
"esModuleInterop": true
},
"include": [
"src/**/*"
Expand Down
14 changes: 14 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7b7415c

Please sign in to comment.