KiCad PCB EDA Suite
Loading...
Searching...
No Matches
command_sch_upgrade.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "command_sch_upgrade.h"
22#include "cli/exit_codes.h"
23#include <wx/crt.h>
24
25#define ARG_FORCE "--force"
26
28 COMMAND( "upgrade" )
29{
30 addCommonArgs( true, false, false, false );
31 m_argParser.add_description( UTF8STDSTR( _( "Upgrade the schematic file's format to the latest one" ) ) );
32
33 m_argParser.add_argument( ARG_FORCE )
34 .help( UTF8STDSTR( _( "Forces the schematic file to be resaved regardless of versioning" ) ) )
35 .flag();
36}
37
39{
40 std::unique_ptr<JOB_SCH_UPGRADE> upgradeJob = std::make_unique<JOB_SCH_UPGRADE>();
41
42 upgradeJob->m_filename = m_argInput;
43 upgradeJob->m_force = m_argParser.get<bool>( ARG_FORCE );
44
45 if( !wxFile::Exists( upgradeJob->m_filename ) )
46 {
47 wxFprintf( stderr, _( "Schematic file does not exist or is not accessible\n" ) );
49 }
50
51 int exitCode = aKiway.ProcessJob( KIWAY::FACE_SCH, upgradeJob.get() );
52
53 return exitCode;
54}
void addCommonArgs(bool aInput, bool aOutput, bool aInputCanBeDir, bool aOutputIsDir)
Set up the most common of args used across cli.
Definition command.cpp:115
argparse::ArgumentParser m_argParser
Definition command.h:100
COMMAND(const std::string &aName)
Define a new COMMAND instance.
Definition command.cpp:30
wxString m_argInput
Value of the common input arg if configured.
Definition command.h:130
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition kiway.h:286
int ProcessJob(KIWAY::FACE_T aFace, JOB *aJob, REPORTER *aReporter=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr)
Definition kiway.cpp:701
@ FACE_SCH
eeschema DSO
Definition kiway.h:293
#define UTF8STDSTR(s)
Definition command.h:27
#define ARG_FORCE
#define _(s)
static const int ERR_INVALID_INPUT_FILE
Definition exit_codes.h:33
int doPerform(KIWAY &aKiway) override
The internal handler that should be overloaded to implement command specific processing and work.