//
// aegis - project change supervisor
// Copyright (C) 2002-2008, 2011, 2012 Peter Miller
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see
// .
//
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
static void
destructor(command_ty *)
{
}
static complete_ty *
completion_get(command_ty *)
{
complete_ty *result;
string_ty *project_name;
project *pp;
int incomplete_change_number;
arglex2_retable(0);
arglex();
project_name = 0;
incomplete_change_number = 0;
while (arglex_token != arglex_token_eoln)
{
switch (arglex_token)
{
default:
result = generic_argument_complete();
if (result)
return result;
continue;
case arglex_token_change:
switch (arglex())
{
default:
continue;
case arglex_token_number:
break;
case arglex_token_number_incomplete:
case arglex_token_string_incomplete:
incomplete_change_number = 1;
break;
}
break;
case arglex_token_number:
break;
case arglex_token_number_incomplete:
incomplete_change_number = 1;
break;
case arglex_token_project:
switch (arglex())
{
default:
continue;
case arglex_token_string:
project_name = str_from_c(arglex_value.alv_string);
break;
case arglex_token_string_incomplete:
case arglex_token_number_incomplete:
return complete_project_name();
}
break;
case arglex_token_string:
project_name = str_from_c(arglex_value.alv_string);
break;
case arglex_token_string_incomplete:
return complete_project_name();
}
arglex();
}
//
// Work out which project to use.
//
if (!project_name)
{
nstring n = user_ty::create()->default_project();
project_name = str_copy(n.get_ref());
}
pp = project_alloc(project_name);
pp->bind_existing();
//
// If we need to complete a change number, we have the project now.
//
if (incomplete_change_number)
return complete_change_number(pp, 1 << cstate_state_being_developed);
//
// What are they smoking?
//
return complete_nil();
}
static command_vtbl_ty vtbl =
{
destructor,
completion_get,
sizeof(command_ty),
"aeclean",
};
command_ty *
command_aeclean()
{
return command_new(&vtbl);
}
// vim: set ts=8 sw=4 et :