Skip to content

Commit 93ae932

Browse files
committed
Add session default for session shell
1 parent e8591c8 commit 93ae932

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
lines changed

src/windows/wslc/commands/SessionShellCommand.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace wsl::windows::wslc {
2424
std::vector<Argument> SessionShellCommand::GetArguments() const
2525
{
2626
return {
27-
Argument::Create(ArgType::SessionId, true),
27+
Argument::Create(ArgType::SessionId),
2828
};
2929
}
3030

@@ -35,7 +35,7 @@ std::wstring SessionShellCommand::ShortDescription() const
3535

3636
std::wstring SessionShellCommand::LongDescription() const
3737
{
38-
return {L"Attaches to an active session."};
38+
return {L"Attaches to an active session. If no session ID is provided, the default session will be used."};
3939
}
4040

4141
void SessionShellCommand::ExecuteInternal(CLIExecutionContext& context) const

src/windows/wslc/services/SessionModel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ SessionOptions SessionOptions::Default()
2323

2424
// TODO: Have a configuration file for those.
2525
SessionOptions options{};
26-
options.m_sessionSettings.DisplayName = L"wsla-cli";
26+
options.m_sessionSettings.DisplayName = s_DefaultSessionName.data();
2727
options.m_sessionSettings.CpuCount = 4;
2828
options.m_sessionSettings.MemoryMb = 2048;
2929
options.m_sessionSettings.BootTimeoutMs = 30 * 1000;

src/windows/wslc/services/SessionModel.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ Module Name:
1717
#include <wslaservice.h>
1818

1919
namespace wsl::windows::wslc::models {
20+
21+
constexpr std::wstring_view s_DefaultSessionName = L"wsla-cli";
22+
2023
struct Session
2124
{
2225
explicit Session(wil::com_ptr<IWSLASession> session) : m_session(std::move(session))

src/windows/wslc/tasks/SessionTasks.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,17 @@ namespace wsl::windows::wslc::task {
2929

3030
void AttachToSession(CLIExecutionContext& context)
3131
{
32-
WI_ASSERT(context.Args.Contains(ArgType::SessionId));
33-
context.ExitCode = SessionService::Attach(context.Args.Get<ArgType::SessionId>());
32+
std::wstring sessionId;
33+
if (context.Args.Contains(ArgType::SessionId))
34+
{
35+
sessionId = context.Args.Get<ArgType::SessionId>();
36+
}
37+
else
38+
{
39+
sessionId = models::s_DefaultSessionName.data();
40+
}
41+
42+
context.ExitCode = SessionService::Attach(sessionId);
3443
}
3544

3645
void CreateSession(CLIExecutionContext& context)

test/windows/wslc/CommandLineTestCases.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ COMMAND_LINE_TEST_CASE(L"session list --verbose --help", L"list", true)
3232
COMMAND_LINE_TEST_CASE(L"session list --notanarg", L"list", false)
3333
COMMAND_LINE_TEST_CASE(L"session list extraarg", L"list", false)
3434
COMMAND_LINE_TEST_CASE(L"session shell session1", L"shell", true)
35+
COMMAND_LINE_TEST_CASE(L"session shell", L"shell", true)
3536

3637
// Container command tests
3738
COMMAND_LINE_TEST_CASE(L"container list", L"list", true)

0 commit comments

Comments
 (0)