Skip to content

Commit f342e86

Browse files
committed
feat: refine first-run setup logic to allow commands like help and config without configuration
- this should ensure tests run properly when not config is set
1 parent 53b4b9a commit f342e86

File tree

1 file changed

+6
-26
lines changed

1 file changed

+6
-26
lines changed

src/Program.cs

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -123,20 +123,13 @@ public static async Task<int> Main(string[] args)
123123

124124
using var serviceProvider = services.BuildServiceProvider();
125125

126-
// Check if help is requested - bypass setup for help commands
127-
// This allows --help to work even when the app is not configured
128-
bool isHelpRequested = args.Any(arg =>
129-
arg.Equals("--help", StringComparison.OrdinalIgnoreCase) ||
130-
arg.Equals("-h", StringComparison.OrdinalIgnoreCase) ||
131-
arg.Equals("-?", StringComparison.OrdinalIgnoreCase) ||
132-
arg.Equals("/?", StringComparison.OrdinalIgnoreCase));
133-
134-
// Check if first-run setup is needed (unless running setup command explicitly or requesting help)
135-
bool isSetupCommand = args.Length > 0 && args[0].Equals("setup", StringComparison.OrdinalIgnoreCase);
126+
// Check if first-run setup is needed (only when no args or entering shell mode)
127+
// Commands like help, config, setup, version should always work without configuration
136128
bool isConfigured = ConfigurationChecker.IsConfigured(configuration, logger);
137129

138-
if (!isConfigured && !isSetupCommand && !isHelpRequested)
130+
if (!isConfigured && args.Length == 0)
139131
{
132+
// No arguments and not configured = first-run setup wizard
140133
logger.LogInformation("First-run detected. Launching setup wizard...");
141134
Console.WriteLine();
142135
Console.WriteLine("Welcome to Ten Second Tom! 🎩");
@@ -165,21 +158,8 @@ public static async Task<int> Main(string[] args)
165158
Console.WriteLine();
166159
Console.WriteLine("Setup complete! You can now use Ten Second Tom.");
167160
Console.WriteLine();
168-
169-
// If user ran a command, execute it now after successful setup
170-
if (args.Length > 0)
171-
{
172-
logger.LogInformation("Executing original command after setup");
173-
Console.WriteLine($"Executing: {string.Join(" ", args)}");
174-
Console.WriteLine();
175-
}
176-
else
177-
{
178-
// No command specified, show help
179-
logger.LogInformation("No command specified, displaying help");
180-
Console.WriteLine("Try 'tom today' to record what you're working on.");
181-
return 0;
182-
}
161+
Console.WriteLine("Try 'tom today' to record what you're working on.");
162+
return 0;
183163
}
184164

185165
// Determine execution mode: shell or single command

0 commit comments

Comments
 (0)