Skip to content

Commit

Permalink
Merge pull request #11 from russel-io/fixBug
Browse files Browse the repository at this point in the history
Fix bug
  • Loading branch information
SaeedSafi1999 authored Aug 28, 2024
2 parents 09c8714 + 895887c commit c600892
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions russel-cli/Commandhandlers/CommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static async Task HandleCommand(ApiClient client)
if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password))
{
"You must provide a user_name and password.".WriteError();
continue;
continue;
}

var result = await client.Authenticate(userName, password);
Expand All @@ -61,7 +61,7 @@ public static async Task HandleCommand(ApiClient client)
else
{
"Authentication failed.".WriteError();
continue;
continue;
}
}

Expand All @@ -81,35 +81,43 @@ public static async Task HandleCommand(ApiClient client)
var user = parts[1];
var password = parts[2];
var role = parts[3];
await client.AddUser(user, password,role,mainUserName,mainPassword);
await client.AddUser(user, password, role, mainUserName, mainPassword);
break;
}
case "ping":
{
await client.CheckConnection();
break;
}
case "set" when parts.Length == 5 || parts.Length == 4:
case "set" when parts.Length == 3:
{
var cluster = parts[1];
var key = parts[2];
var value = parts[3];
"value:".WriteResponse();
var value = Console.ReadLine();
if (string.IsNullOrEmpty(value))
{
"error value can not be bull".WriteError();
break;
}
"ttl:".WriteResponse();
var ttl = Console.ReadLine();

if (parts.Length == 4)
if (string.IsNullOrEmpty(ttl))
{
await client.Set(cluster, key, value, mainUserName, mainPassword);
}
else
{
var expireTime = Convert.ToInt64(parts[4]);
var expireTime = Convert.ToInt64(ttl);
await client.Set(cluster, key, value, mainUserName, mainPassword, expireTime);
}
break;
}
case "set_cluster" when parts.Length == 2:
{
var cluster = parts[1];
await client.SetCluster(cluster,mainUserName,mainPassword);
await client.SetCluster(cluster, mainUserName, mainPassword);
break;
}
case "keys*" when parts.Length == 2:
Expand Down

0 comments on commit c600892

Please sign in to comment.