New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

mydata-cli

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mydata-cli - npm Package Compare versions

Comparing version
1.0.5
to
1.0.6
+174
commands/todo.js
import { Command } from "commander";
import { api } from "../utils/api.js";
const todo = new Command("todo").description("Manage todo tasks");
// ✅ List todos with optional status filter
todo
.command("list")
.description("List all todos (optionally filtered by status)")
.option("-s, --status <status>", "Filter by status: completed or pending")
.action(async (options) => {
try {
const res = await api.get("/api/todos");
let todos = res.data.data;
if (
options.status === "completed" ||
options.status === "done" ||
options.status === "finished" ||
options.status === "d" ||
options.status === "c" ||
options.status === "yes" ||
options.status === "y"
) {
todos = todos.filter((t) => t.completed);
} else if (
options.status === "pending" ||
options.status === "not done" ||
options.status === "n" ||
options.status === "no" ||
options.status === "undone" ||
options.status === "not completed" ||
options.status === "notfinished"
) {
todos = todos.filter((t) => !t.completed);
}
if (!todos.length) return console.log("No matching tasks found.");
todos.forEach((t) => {
console.log(`${t.completed ? "✅" : "❌"} ${t.text}`);
console.log(`ID: ${t._id}\n`);
});
} catch (err) {
console.error("❌", err.response?.data?.error || err.message);
}
});
// ➕ Add new todo
todo
.command("add <text>")
.description("Add a new todo task")
.action(async (text) => {
try {
const res = await api.post("/api/todos", { text,completed: false });
console.log("✅ Task added:", res.data.data);
} catch (err) {
console.error("❌", err.response?.data?.error || err.message);
}
});
// ✏️ Edit text of a todo
todo
.command("edit <id> <text>")
.description("Edit the text of a todo")
.action(async (id, text) => {
try {
const res = await api.patch("/api/todos", {
id,
updates: { text },
});
console.log("✏️ Updated task:", res.data.data.text);
} catch (err) {
console.error("❌", err.response?.data?.error || err.message);
}
});
// ✔️ Mark as done
todo
.command("done <id>")
.description("Mark a todo as completed")
.action(async (id) => {
try {
const res = await api.patch("/api/todos", {
id,
updates: { completed: true },
});
console.log("✅ Marked as done:", res.data.data.text);
} catch (err) {
console.error("❌", err.response?.data?.error || err.message);
}
});
// ❌ Mark as not done
todo
.command("undone <id>")
.description("Mark a todo as not completed")
.action(async (id) => {
try {
const res = await api.patch("/api/todos", {
id,
updates: { completed: false },
});
console.log("❌ Marked as not done:", res.data.data.text);
} catch (err) {
console.error("❌", err.response?.data?.error || err.message);
}
});
// 🗑️ Delete a todo
todo
.command("delete <id>")
.description("Delete a todo")
.action(async (id) => {
try {
await api.delete(`/api/todos?id=${id}`);
console.log("🗑️ Task deleted");
} catch (err) {
console.error("❌", err.response?.data?.error || err.message);
}
});
// ✔️ Batch mark as done
todo
.command("done-many <ids...>")
.description("Mark multiple tasks as completed")
.action(async (ids) => {
try {
for (const id of ids) {
await api.patch("/api/todos", {
id,
updates: { completed: true },
});
console.log(`✅ Marked done: ${id}`);
}
} catch (err) {
console.error("❌", err.response?.data?.error || err.message);
}
});
// ❌ Batch mark as not done
todo
.command("undone-many <ids...>")
.description("Mark multiple tasks as not completed")
.action(async (ids) => {
try {
for (const id of ids) {
await api.patch("/api/todos", {
id,
updates: { completed: false },
});
console.log(`❌ Marked undone: ${id}`);
}
} catch (err) {
console.error("❌", err.response?.data?.error || err.message);
}
});
// 🗑️ Batch delete
todo
.command("delete-many <ids...>")
.description("Delete multiple tasks")
.action(async (ids) => {
try {
for (const id of ids) {
await api.delete(`/api/todos?id=${id}`);
console.log(`🗑️ Deleted: ${id}`);
}
} catch (err) {
console.error("❌", err.response?.data?.error || err.message);
}
});
export default todo;
+4
-0

@@ -5,2 +5,4 @@ #!/usr/bin/env node

import projectCommand from "../commands/project.js";
import configCommand from "../commands/config.js";
import todoCommand from "../commands/todo.js";

@@ -16,3 +18,5 @@ const program = new Command();

program.addCommand(projectCommand);
program.addCommand(configCommand);
program.addCommand(todoCommand);
program.parse(process.argv);
+1
-1
{
"name": "mydata-cli",
"version": "1.0.5",
"version": "1.0.6",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

import fs from "fs-extra";
import os from "os";
import path from "path";
const configPath = path.join(os.homedir(), ".mycli-config.json");
const configPath = "./mycli-config.json";

@@ -6,0 +4,0 @@ export function saveToken(token) {