Skip to content

Commit cefe4fb

Browse files
authored
Merge pull request #82 from rprouse/edit
Edit command launches VS Code
2 parents 1212f63 + dab5f62 commit cefe4fb

File tree

13 files changed

+122
-17
lines changed

13 files changed

+122
-17
lines changed

.vscode/launch.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "C#: todo Debug",
9+
"type": "dotnet",
10+
"request": "launch",
11+
"projectPath": "${workspaceFolder}/src/todo/todo.csproj"
12+
}
13+
]
14+
}

Help.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ Marks task(s) on line ITEM# as done in todo.txt.
7777
todo do ITEM#[, ITEM#, ITEM#, ...]
7878
```
7979

80+
### `edit`
81+
Opens the folder containing the todo.txt file in VS Code.
82+
83+
```shell
84+
todo edit
85+
```
86+
8087
### `help`
8188
Display help about usage, options, built-in and add-on actions, or just the usage
8289
help for the passed ACTION(s).

Readme.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ remain faithful to the command line and functionality of the original shell scri
77
possible. As such, the [usage](#usage) below is a modified copy of the
88
[original on GitHub](https://github.com/todotxt/todo.txt-cli/blob/master/USAGE.md).
99

10-
- [Installation](#installation)
11-
- [Usage](#usage)
12-
- [Configuration](#configuration)
10+
- [Dotnet Todo.txt CLI](#dotnet-todotxt-cli)
11+
- [Installation](#installation)
12+
- [Enabling Tab Completion](#enabling-tab-completion)
13+
- [Usage](#usage)
14+
- [Commands](#commands)
15+
- [Warning](#warning)
16+
- [Configuration](#configuration)
1317

1418
## Installation
1519

@@ -41,6 +45,27 @@ For a complete list of options,
4145
todo --help
4246
```
4347

48+
### Commands
49+
50+
- **add**: Adds a task to your todo.txt file.
51+
- **addm**: Adds multiple tasks to your todo.txt file.
52+
- **addto**: Adds a line of text to any file located in the todo.txt directory.
53+
- **append**: Adds text to the end of a task.
54+
- **archive**: Moves all done tasks from todo.txt to done.txt and removes blank lines.
55+
- **delete**: Deletes a task or a term from a task.
56+
- **depri**: Deprioritizes (removes the priority) from tasks.
57+
- **edit**: Opens the folder containing the todo.txt file in VS Code.
58+
- **do**: Marks tasks as done in todo.txt.
59+
- **list**: Displays tasks that match terms sorted by priority.
60+
- **listall**: Displays all tasks in todo.txt and done.txt that match terms.
61+
- **listcon**: Lists all task contexts starting with @.
62+
- **listfile**: Displays tasks from a specific file that match terms.
63+
- **listpri**: Displays prioritized tasks that match terms.
64+
- **listproj**: Lists all projects starting with +.
65+
- **prepend**: Adds text to the beginning of a task.
66+
- **pri**: Adds or updates the priority of a task.
67+
- **replace**: Replaces a task with updated text.
68+
4469
### Warning
4570

4671
The Windows command line uses the `@` sign to indicate that command line arguments should be loaded from
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using Alteridem.Todo.Domain.Interfaces;
2+
using MediatR;
3+
using System.Threading;
4+
using System.Threading.Tasks;
5+
6+
namespace Alteridem.Todo.Application.Commands
7+
{
8+
public class EditTodoCommand : IRequest<Unit>
9+
{
10+
// No parameters for this command
11+
}
12+
13+
public class EditTodoCommandHandler : IRequestHandler<EditTodoCommand, Unit>
14+
{
15+
private readonly ITaskConfiguration _configuration;
16+
17+
public EditTodoCommandHandler(ITaskConfiguration configuration)
18+
{
19+
_configuration = configuration;
20+
}
21+
22+
public Task<Unit> Handle(EditTodoCommand request, CancellationToken cancellationToken)
23+
{
24+
// Step 1: Get the directory that contains todo.txt from the configuration
25+
var todoDirectory = _configuration.TodoDirectory;
26+
27+
// Step 2: Launch a process 'code' with the todoDirectory as a parameter
28+
var processStartInfo = new System.Diagnostics.ProcessStartInfo
29+
{
30+
FileName = "code",
31+
Arguments = $"\"{todoDirectory}\"",
32+
UseShellExecute = true,
33+
CreateNoWindow = true,
34+
WorkingDirectory = $"\"{todoDirectory}\"",
35+
};
36+
System.Diagnostics.Process.Start(processStartInfo);
37+
38+
// Stub implementation for editing logic
39+
return Task.FromResult(Unit.Value);
40+
}
41+
}
42+
}

src/todo.application/todo.application.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.1</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<AssemblyName>Todo.Application</AssemblyName>
66
<RootNamespace>Alteridem.Todo.Application</RootNamespace>
77
<Company>Alteridem Consulting</Company>
88
<Product>Todo.txt command line utility application library</Product>
9-
<Copyright>Copyright (c) 2023 Rob Prouse</Copyright>
10-
<LangVersion>10</LangVersion>
9+
<Copyright>Copyright (c) 2025 Rob Prouse</Copyright>
10+
<LangVersion>12</LangVersion>
1111
</PropertyGroup>
1212

1313
<!-- Make Internals visible to the unit tests -->

src/todo.domain/todo.domain.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.1</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<AssemblyName>Todo.Domain</AssemblyName>
66
<RootNamespace>Alteridem.Todo.Domain</RootNamespace>
77
<Company>Alteridem Consulting</Company>
88
<Product>Todo.txt command line utility domain library</Product>
9-
<Copyright>Copyright (c) 2023 Rob Prouse</Copyright>
10-
<LangVersion>10</LangVersion>
9+
<Copyright>Copyright (c) 2025 Rob Prouse</Copyright>
10+
<LangVersion>12</LangVersion>
1111
</PropertyGroup>
1212

1313
</Project>

src/todo.infrastructure/DependencyInjection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static IServiceCollection AddInfrastructure(this IServiceCollection servi
2323
var options = new JsonSerializerOptions
2424
{
2525
AllowTrailingCommas = true,
26-
IgnoreNullValues = true,
26+
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
2727
ReadCommentHandling = JsonCommentHandling.Skip,
2828
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
2929
WriteIndented = true

src/todo.infrastructure/todo.infrastructure.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.1</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<AssemblyName>Todo.Infrastructure</AssemblyName>
66
<RootNamespace>Alteridem.Todo.Infrastructure</RootNamespace>
77
<Company>Alteridem Consulting</Company>
88
<Product>Todo.txt command line utility infrastructure library</Product>
9-
<Copyright>Copyright (c) 2023 Rob Prouse</Copyright>
10-
<LangVersion>10</LangVersion>
9+
<Copyright>Copyright (c) 2025 Rob Prouse</Copyright>
10+
<LangVersion>12</LangVersion>
1111
</PropertyGroup>
1212

1313
<ItemGroup>

src/todo/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ namespace Alteridem.Todo;
22

33
class Program
44
{
5-
static void Main()
5+
static void Main(string[] args)
66
{
77
var app = new TodoApplication();
88
app.Run();

src/todo/Properties/launchSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"profiles": {
33
"todo": {
44
"commandName": "Project",
5-
"commandLineArgs": "ls"
5+
"commandLineArgs": "edit"
66
}
77
}
88
}

0 commit comments

Comments
 (0)