up -l tag to supoort input
its used to filter witch labels to show
This commit is contained in:
parent
b4d4f57051
commit
7cc33550c4
@ -34,7 +34,7 @@ void arg_username(Buffer &decrypted_buffer, Buffer &encrypted_buffer, const char
|
|||||||
|
|
||||||
void arg_label_name(Buffer &decrypted_buffer, Buffer &encrypted_buffer, const char *label, std::string &key);
|
void arg_label_name(Buffer &decrypted_buffer, Buffer &encrypted_buffer, const char *label, std::string &key);
|
||||||
|
|
||||||
void arg_list(Buffer &decrypted_buffer);
|
void arg_list(Buffer &decrypted_buffer, const char *label_filter);
|
||||||
|
|
||||||
void arg_delete(Buffer &decrypted_buffer, Buffer &encrypted_buffer, const char *label, std::string &key);
|
void arg_delete(Buffer &decrypted_buffer, Buffer &encrypted_buffer, const char *label, std::string &key);
|
||||||
|
|
||||||
|
@ -38,6 +38,8 @@ void print_args()
|
|||||||
|
|
||||||
Arg get_args(int argc, char **argv, char **label)
|
Arg get_args(int argc, char **argv, char **label)
|
||||||
{
|
{
|
||||||
|
Arg ret = Arg::Error;
|
||||||
|
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
{
|
{
|
||||||
print_args();
|
print_args();
|
||||||
@ -56,15 +58,22 @@ Arg get_args(int argc, char **argv, char **label)
|
|||||||
print_args();
|
print_args();
|
||||||
return Arg::Error;
|
return Arg::Error;
|
||||||
case 'l':
|
case 'l':
|
||||||
return Arg::List;
|
ret = Arg::List;
|
||||||
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
return Arg::Print_all_p;
|
ret = Arg::Print_all_p;
|
||||||
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
return Arg::Change;
|
ret = Arg::Change;
|
||||||
|
break;
|
||||||
case 'z':
|
case 'z':
|
||||||
return Arg::Size;
|
ret = Arg::Size;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (argc == 2)
|
||||||
|
return ret;
|
||||||
|
|
||||||
if (argc != 3)
|
if (argc != 3)
|
||||||
return Arg::Error;
|
return Arg::Error;
|
||||||
|
|
||||||
@ -90,7 +99,7 @@ Arg get_args(int argc, char **argv, char **label)
|
|||||||
return Arg::Editor;
|
return Arg::Editor;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return Arg::Error;
|
return ret;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,7 +226,7 @@ void arg_label_name(Buffer &decrypted_buffer, Buffer &encrypted_buffer, const ch
|
|||||||
encrypted_buffer.save_to_file();
|
encrypted_buffer.save_to_file();
|
||||||
}
|
}
|
||||||
|
|
||||||
void arg_list(Buffer &decrypted_buffer)
|
void arg_list(Buffer &decrypted_buffer, const char *label_filter)
|
||||||
{
|
{
|
||||||
Index *index = (Index *)decrypted_buffer.buffer;
|
Index *index = (Index *)decrypted_buffer.buffer;
|
||||||
LoginInfo *pass = (LoginInfo *)(decrypted_buffer.buffer + sizeof(Index));
|
LoginInfo *pass = (LoginInfo *)(decrypted_buffer.buffer + sizeof(Index));
|
||||||
@ -226,7 +235,15 @@ void arg_list(Buffer &decrypted_buffer)
|
|||||||
|
|
||||||
for (size_t i = 0; i < index->count; i++)
|
for (size_t i = 0; i < index->count; i++)
|
||||||
{
|
{
|
||||||
list.emplace_back(std::string((char *)decrypted_buffer.buffer + pass[i].label + index->offset));
|
const char *str = (const char *)decrypted_buffer.buffer + pass[i].label + index->offset;
|
||||||
|
if (!label_filter)
|
||||||
|
{
|
||||||
|
list.emplace_back(std::string(str));
|
||||||
|
}
|
||||||
|
else if (label_filter[0] == str[0])
|
||||||
|
{
|
||||||
|
list.emplace_back(std::string(str));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::sort(list.begin(), list.end());
|
std::sort(list.begin(), list.end());
|
||||||
|
@ -102,7 +102,7 @@ int main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Arg::List:
|
case Arg::List:
|
||||||
arg_list(decrypted_buffer);
|
arg_list(decrypted_buffer, label);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Arg::Delete:
|
case Arg::Delete:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user