Confirmation
- The 'delete' command now requires confirmation by default, unless rc.confirmation=off. Implemented properly this time.
This commit is contained in:
@@ -45,6 +45,7 @@ CmdDelete::CmdDelete ()
|
|||||||
_description = STRING_CMD_DELETE_USAGE;
|
_description = STRING_CMD_DELETE_USAGE;
|
||||||
_read_only = false;
|
_read_only = false;
|
||||||
_displays_id = false;
|
_displays_id = false;
|
||||||
|
_needs_confirm = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -199,6 +199,7 @@ Command::Command ()
|
|||||||
, _description ("")
|
, _description ("")
|
||||||
, _read_only (true)
|
, _read_only (true)
|
||||||
, _displays_id (true)
|
, _displays_id (true)
|
||||||
|
, _needs_confirm (false)
|
||||||
, _permission_quit (false)
|
, _permission_quit (false)
|
||||||
, _permission_all (false)
|
, _permission_all (false)
|
||||||
{
|
{
|
||||||
@@ -211,6 +212,7 @@ Command::Command (const Command& other)
|
|||||||
_description = other._description;
|
_description = other._description;
|
||||||
_read_only = other._read_only;
|
_read_only = other._read_only;
|
||||||
_displays_id = other._displays_id;
|
_displays_id = other._displays_id;
|
||||||
|
_needs_confirm = other._needs_confirm;
|
||||||
_permission_quit = other._permission_quit;
|
_permission_quit = other._permission_quit;
|
||||||
_permission_all = other._permission_all;
|
_permission_all = other._permission_all;
|
||||||
}
|
}
|
||||||
@@ -224,6 +226,7 @@ Command& Command::operator= (const Command& other)
|
|||||||
_description = other._description;
|
_description = other._description;
|
||||||
_read_only = other._read_only;
|
_read_only = other._read_only;
|
||||||
_displays_id = other._displays_id;
|
_displays_id = other._displays_id;
|
||||||
|
_needs_confirm = other._needs_confirm;
|
||||||
_permission_quit = other._permission_quit;
|
_permission_quit = other._permission_quit;
|
||||||
_permission_all = other._permission_all;
|
_permission_all = other._permission_all;
|
||||||
}
|
}
|
||||||
@@ -234,10 +237,11 @@ Command& Command::operator= (const Command& other)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
bool Command::operator== (const Command& other) const
|
bool Command::operator== (const Command& other) const
|
||||||
{
|
{
|
||||||
return _usage == other._usage &&
|
return _usage == other._usage &&
|
||||||
_description == other._description &&
|
_description == other._description &&
|
||||||
_read_only == other._read_only &&
|
_read_only == other._read_only &&
|
||||||
_displays_id == other._displays_id;
|
_displays_id == other._displays_id &&
|
||||||
|
_needs_confirm == other._needs_confirm;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -589,7 +593,8 @@ bool Command::permission (
|
|||||||
// Quantity 1 modifications have optional confirmation, and only (y/n).
|
// Quantity 1 modifications have optional confirmation, and only (y/n).
|
||||||
if (quantity == 1)
|
if (quantity == 1)
|
||||||
{
|
{
|
||||||
if (!confirmation)
|
if (!_needs_confirm ||
|
||||||
|
!confirmation)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
bool answer = confirm (question);
|
bool answer = confirm (question);
|
||||||
@@ -598,7 +603,7 @@ bool Command::permission (
|
|||||||
|
|
||||||
// 1 < Quantity < bulk modifications have optional confirmation, in the (y/n/a/q)
|
// 1 < Quantity < bulk modifications have optional confirmation, in the (y/n/a/q)
|
||||||
// style.
|
// style.
|
||||||
if (quantity < bulk && !confirmation)
|
if (quantity < bulk && (!_needs_confirm || !confirmation))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
int answer = confirm4 (question);
|
int answer = confirm4 (question);
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ protected:
|
|||||||
std::string _description;
|
std::string _description;
|
||||||
bool _read_only;
|
bool _read_only;
|
||||||
bool _displays_id;
|
bool _displays_id;
|
||||||
|
bool _needs_confirm;
|
||||||
|
|
||||||
// Permission support
|
// Permission support
|
||||||
bool _permission_quit;
|
bool _permission_quit;
|
||||||
|
|||||||
Reference in New Issue
Block a user