132 changed files with 15046 additions and 306 deletions
-
4CMakeLists.txt
-
1bitmap2component/CMakeLists.txt
-
8common/CMakeLists.txt
-
48common/cli/command.h
-
31common/cli/command_export_kicad_pcbnew.cpp
-
36common/cli/command_export_kicad_pcbnew.h
-
126common/cli/command_export_pcb_svg.cpp
-
36common/cli/command_export_pcb_svg.h
-
30common/cli/command_export_pcbnew.cpp
-
36common/cli/command_export_pcbnew.h
-
174common/cli/command_export_step.cpp
-
36common/cli/command_export_step.h
-
38common/cli/exit_codes.h
-
42common/jobs/job.h
-
38common/jobs/job_dispatcher.cpp
-
39common/jobs/job_dispatcher.h
-
49common/jobs/job_export_pcb_svg.h
-
34common/jobs/job_export_step.cpp
-
45common/jobs/job_export_step.h
-
8common/kiway.cpp
-
24common/pgm_base.cpp
-
148common/single_top.cpp
-
3eeschema/CMakeLists.txt
-
7eeschema/eeschema.cpp
-
1gerbview/CMakeLists.txt
-
8include/kiway.h
-
14include/kiway_player.h
-
10include/pgm_base.h
-
7kicad/CMakeLists.txt
-
87kicad/kicad.cpp
-
25libs/kiplatform/msw/app.cpp
-
1pagelayout_editor/CMakeLists.txt
-
1pcb_calculator/CMakeLists.txt
-
14pcbnew/CMakeLists.txt
-
68pcbnew/dialogs/dialog_export_step.cpp
-
81pcbnew/dialogs/dialog_export_svg.cpp
-
36pcbnew/exporters/step/CMakeLists.txt
-
146pcbnew/exporters/step/kicad2step.cpp
-
11pcbnew/exporters/step/kicad2step.h
-
0pcbnew/exporters/step/kicad2step_app.cpp
-
4pcbnew/exporters/step/kicad2step_frame_base.cpp
-
6pcbnew/exporters/step/kicad2step_frame_base.fbp
-
3pcbnew/exporters/step/kicad2step_frame_base.h
-
4pcbnew/exporters/step/panel_kicad2step.h
-
2pcbnew/exporters/step/pcb/3d_resolver.cpp
-
0pcbnew/exporters/step/pcb/3d_resolver.h
-
0pcbnew/exporters/step/pcb/base.cpp
-
0pcbnew/exporters/step/pcb/base.h
-
0pcbnew/exporters/step/pcb/kicadcurve.cpp
-
0pcbnew/exporters/step/pcb/kicadcurve.h
-
0pcbnew/exporters/step/pcb/kicadfootprint.cpp
-
0pcbnew/exporters/step/pcb/kicadfootprint.h
-
0pcbnew/exporters/step/pcb/kicadmodel.cpp
-
0pcbnew/exporters/step/pcb/kicadmodel.h
-
0pcbnew/exporters/step/pcb/kicadpad.cpp
-
0pcbnew/exporters/step/pcb/kicadpad.h
-
0pcbnew/exporters/step/pcb/kicadpcb.cpp
-
0pcbnew/exporters/step/pcb/kicadpcb.h
-
0pcbnew/exporters/step/pcb/oce_utils.cpp
-
0pcbnew/exporters/step/pcb/oce_utils.h
-
106pcbnew/pcb_plot_svg.cpp
-
43pcbnew/pcb_plot_svg.h
-
13pcbnew/pcbnew.cpp
-
102pcbnew/pcbnew_jobs_handler.cpp
-
34pcbnew/pcbnew_jobs_handler.h
-
5qa/tools/pcbnew_tools/CMakeLists.txt
-
1resources/msw/cmd-wrappers/kicad.cmd
-
1resources/msw/cmd-wrappers/pcbnew.cmd
-
1thirdparty/CMakeLists.txt
-
117thirdparty/argparse/.clang-format
-
21thirdparty/argparse/.clang-tidy
-
87thirdparty/argparse/.github/workflows/ci.yml
-
273thirdparty/argparse/.gitignore
-
39thirdparty/argparse/.travis.yml
-
98thirdparty/argparse/CMakeLists.txt
-
17thirdparty/argparse/CONTRIBUTING.md
-
7thirdparty/argparse/LICENSE
-
1143thirdparty/argparse/README.md
-
1thirdparty/argparse/clang_format.bash
-
10thirdparty/argparse/conanfile.py
-
1652thirdparty/argparse/include/argparse/argparse.hpp
-
7thirdparty/argparse/packaging/pkgconfig.pc.in
-
46thirdparty/argparse/samples/CMakeLists.txt
-
36thirdparty/argparse/samples/compound_arguments.cpp
-
27thirdparty/argparse/samples/custom_assignment_characters.cpp
-
31thirdparty/argparse/samples/custom_prefix_characters.cpp
-
17thirdparty/argparse/samples/description_epilog_metavar.cpp
-
24thirdparty/argparse/samples/gathering_remaining_arguments.cpp
-
26thirdparty/argparse/samples/is_used.cpp
-
28thirdparty/argparse/samples/joining_repeated_optional_arguments.cpp
-
30thirdparty/argparse/samples/list_of_arguments.cpp
-
32thirdparty/argparse/samples/negative_numbers.cpp
-
22thirdparty/argparse/samples/optional_flag_argument.cpp
-
26thirdparty/argparse/samples/parse_known_args.cpp
-
28thirdparty/argparse/samples/positional_argument.cpp
-
17thirdparty/argparse/samples/repeating_argument_to_increase_value.cpp
-
19thirdparty/argparse/samples/required_optional_argument.cpp
-
65thirdparty/argparse/samples/subcommands.cpp
-
2thirdparty/argparse/test/.gitignore
-
63thirdparty/argparse/test/CMakeLists.txt
@ -0,0 +1,48 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com> |
|||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* 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 <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef CLI_COMMAND_H |
|||
#define CLI_COMMAND_H |
|||
|
|||
#include <argparse/argparse.hpp> |
|||
#include <kiway.h> |
|||
|
|||
namespace CLI |
|||
{ |
|||
|
|||
struct COMMAND |
|||
{ |
|||
COMMAND( std::string aName ) : m_name( aName ), m_argParser( aName ){}; |
|||
|
|||
virtual int Perform( KIWAY& aKiway ) const = 0; |
|||
|
|||
virtual ~COMMAND() = default; |
|||
|
|||
argparse::ArgumentParser& GetArgParser() { return m_argParser; } |
|||
const std::string& GetName() const { return m_name; } |
|||
|
|||
protected: |
|||
std::string m_name; |
|||
argparse::ArgumentParser m_argParser; |
|||
}; |
|||
|
|||
} |
|||
|
|||
#endif |
|||
@ -0,0 +1,31 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com> |
|||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* 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 <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
#include "command_export_kicad_pcbnew.h"
|
|||
|
|||
CLI::EXPORT_KICAD_PCBNEW_COMMAND::EXPORT_KICAD_PCBNEW_COMMAND() : COMMAND( "export-pcb" ) |
|||
{ |
|||
} |
|||
|
|||
|
|||
int CLI::EXPORT_KICAD_PCBNEW_COMMAND::Perform( KIWAY& aKiway ) const |
|||
{ |
|||
return 0; |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com> |
|||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* 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 <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef COMMAND_EXPORT_KICAD_PCBNEW_H |
|||
#define COMMAND_EXPORT_KICAD_PCBNEW_H |
|||
|
|||
#include "command.h" |
|||
|
|||
namespace CLI |
|||
{ |
|||
struct EXPORT_KICAD_PCBNEW_COMMAND : public COMMAND |
|||
{ |
|||
EXPORT_KICAD_PCBNEW_COMMAND(); |
|||
|
|||
int Perform( KIWAY& aKiway ) const override; |
|||
}; |
|||
} |
|||
|
|||
#endif |
|||
@ -0,0 +1,126 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com> |
|||
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com> |
|||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* 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 <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
#include "command_export_pcb_svg.h"
|
|||
#include "exit_codes.h"
|
|||
#include "jobs/job_export_pcb_svg.h"
|
|||
#include <kiface_base.h>
|
|||
#include <layer_ids.h>
|
|||
#include <regex>
|
|||
|
|||
#include <macros.h>
|
|||
#include <wx/tokenzr.h>
|
|||
|
|||
#define ARG_PAGE_SIZE "--page-size-mode"
|
|||
#define ARG_MIRROR "--mirror"
|
|||
#define ARG_BLACKANDWHITE "--black-and-white"
|
|||
#define ARG_OUTPUT "--output"
|
|||
#define ARG_THEME "--theme"
|
|||
#define ARG_LAYERS "--layers"
|
|||
#define ARG_INPUT "input"
|
|||
|
|||
|
|||
CLI::EXPORT_PCB_SVG_COMMAND::EXPORT_PCB_SVG_COMMAND() : COMMAND( "svg" ) |
|||
{ |
|||
m_argParser.add_argument( "-o", ARG_OUTPUT ) |
|||
.default_value( std::string() ) |
|||
.help( "output file name" ); |
|||
|
|||
m_argParser.add_argument( "-l", ARG_LAYERS ) |
|||
.default_value( std::string() ) |
|||
.help( "comma separated list of untranslated layer names to include such as F.Cu,B.Cu" ); |
|||
|
|||
m_argParser.add_argument( "-m", ARG_MIRROR ) |
|||
.help( "Mirror the board (useful for trying to show bottom layers)" ) |
|||
.implicit_value( true ) |
|||
.default_value( false ); |
|||
|
|||
m_argParser.add_argument( "-t", ARG_THEME ) |
|||
.default_value( std::string() ) |
|||
.help( "Color theme to use (will default to pcbnew settings)" ); |
|||
|
|||
m_argParser.add_argument( ARG_BLACKANDWHITE ) |
|||
.help( "Black and white only" ) |
|||
.implicit_value( true ) |
|||
.default_value( false ); |
|||
|
|||
m_argParser.add_argument( ARG_PAGE_SIZE ) |
|||
.help( "Set page sizing mode (0 = page with frame and title block, 1 = current page size, 2 = board area only)" ) |
|||
.default_value( 0 ); |
|||
|
|||
m_argParser.add_argument( ARG_INPUT ).help( "input file" ); |
|||
} |
|||
|
|||
|
|||
int CLI::EXPORT_PCB_SVG_COMMAND::Perform( KIWAY& aKiway ) const |
|||
{ |
|||
std::map<std::string, LSET> layerMasks; |
|||
for( int layer = 0; layer < PCB_LAYER_ID_COUNT; ++layer ) |
|||
{ |
|||
std::string untranslated = TO_UTF8( wxString( LSET::Name( PCB_LAYER_ID( layer ) ) ) ); |
|||
|
|||
//m_layerIndices[untranslated] = PCB_LAYER_ID( layer );
|
|||
layerMasks[untranslated] = LSET( PCB_LAYER_ID( layer ) ); |
|||
} |
|||
layerMasks["*.Cu"] = LSET::AllCuMask(); |
|||
layerMasks["*In.Cu"] = LSET::InternalCuMask(); |
|||
layerMasks["F&B.Cu"] = LSET( 2, F_Cu, B_Cu ); |
|||
layerMasks["*.Adhes"] = LSET( 2, B_Adhes, F_Adhes ); |
|||
layerMasks["*.Paste"] = LSET( 2, B_Paste, F_Paste ); |
|||
layerMasks["*.Mask"] = LSET( 2, B_Mask, F_Mask ); |
|||
layerMasks["*.SilkS"] = LSET( 2, B_SilkS, F_SilkS ); |
|||
layerMasks["*.Fab"] = LSET( 2, B_Fab, F_Fab ); |
|||
layerMasks["*.CrtYd"] = LSET( 2, B_CrtYd, F_CrtYd ); |
|||
|
|||
JOB_EXPORT_PCB_SVG* svgJob = new JOB_EXPORT_PCB_SVG( true ); |
|||
|
|||
svgJob->m_mirror = m_argParser.get<bool>( ARG_MIRROR ); |
|||
svgJob->m_blackAndWhite = m_argParser.get<bool>( ARG_BLACKANDWHITE ); |
|||
svgJob->m_pageSizeMode = m_argParser.get<int>( ARG_PAGE_SIZE ); |
|||
|
|||
svgJob->m_filename = FROM_UTF8( m_argParser.get<std::string>( ARG_INPUT ).c_str() ); |
|||
svgJob->m_outputFile = FROM_UTF8( m_argParser.get<std::string>( ARG_OUTPUT ).c_str() ); |
|||
svgJob->m_colorTheme = FROM_UTF8( m_argParser.get<std::string>( ARG_THEME ).c_str() ); |
|||
|
|||
wxString layers = FROM_UTF8( m_argParser.get<std::string>( ARG_LAYERS ).c_str() ); |
|||
|
|||
LSET layerMask = LSET::AllCuMask(); |
|||
|
|||
if( !layers.IsEmpty() ) |
|||
{ |
|||
layerMask.reset(); |
|||
wxStringTokenizer layerTokens( layers, "," ); |
|||
while( layerTokens.HasMoreTokens() ) |
|||
{ |
|||
std::string token = TO_UTF8(layerTokens.GetNextToken()); |
|||
if( layerMasks.count( token ) ) |
|||
{ |
|||
layerMask |= layerMasks[token]; |
|||
} |
|||
} |
|||
} |
|||
|
|||
svgJob->m_printMaskLayer = layerMask; |
|||
|
|||
int exitCode = aKiway.ProcessJob( KIWAY::FACE_PCB, svgJob ); |
|||
|
|||
return exitCode; |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com> |
|||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* 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 <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef COMMAND_EXPORT_PCB_SVG_H |
|||
#define COMMAND_EXPORT_PCB_SVG_H |
|||
|
|||
#include "command.h" |
|||
|
|||
namespace CLI |
|||
{ |
|||
struct EXPORT_PCB_SVG_COMMAND : public COMMAND |
|||
{ |
|||
EXPORT_PCB_SVG_COMMAND(); |
|||
|
|||
int Perform( KIWAY& aKiway ) const override; |
|||
}; |
|||
} // namespace CLI |
|||
|
|||
#endif |
|||
@ -0,0 +1,30 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com> |
|||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* 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 <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
#include "command_export_pcbnew.h"
|
|||
|
|||
CLI::EXPORT_PCBNEW_COMMAND::EXPORT_PCBNEW_COMMAND() : COMMAND( "export" ) |
|||
{ |
|||
} |
|||
|
|||
int CLI::EXPORT_PCBNEW_COMMAND::Perform( KIWAY& aKiway ) const |
|||
{ |
|||
return 0; |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com> |
|||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* 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 <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef COMMAND_EXPORT_PCBNEW_H |
|||
#define COMMAND_EXPORT_PCBNEW_H |
|||
|
|||
#include "command.h" |
|||
|
|||
namespace CLI |
|||
{ |
|||
struct EXPORT_PCBNEW_COMMAND : public COMMAND |
|||
{ |
|||
EXPORT_PCBNEW_COMMAND(); |
|||
|
|||
int Perform( KIWAY& aKiway ) const override; |
|||
}; |
|||
} |
|||
|
|||
#endif |
|||
@ -0,0 +1,174 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com> |
|||
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com> |
|||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* 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 <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
#include "command_export_step.h"
|
|||
#include "exit_codes.h"
|
|||
#include "jobs/job_export_step.h"
|
|||
#include <kiface_base.h>
|
|||
#include <regex>
|
|||
|
|||
#include <macros.h>
|
|||
|
|||
#define ARG_DRILL_ORIGIN "--drill-origin"
|
|||
#define ARG_GRID_ORIGIN "--grid-origin"
|
|||
#define ARG_NO_VIRTUAL "--no-virtual"
|
|||
#define ARG_SUBST_MODELS "--subst-models"
|
|||
#define ARG_FORCE "--force"
|
|||
#define ARG_OUTPUT "--output"
|
|||
#define ARG_INPUT "input"
|
|||
#define ARG_MIN_DISTANCE "--min-distance"
|
|||
#define ARG_USER_ORIGIN "--user-origin"
|
|||
#define ARG_GUI "--gui"
|
|||
|
|||
#define REGEX_QUANTITY "([\\s]*[+-]?[\\d]*[.]?[\\d]*)"
|
|||
#define REGEX_DELIMITER "(?:[\\s]*x)"
|
|||
#define REGEX_UNIT "([m]{2}|(?:in))"
|
|||
|
|||
CLI::EXPORT_STEP_COMMAND::EXPORT_STEP_COMMAND() : COMMAND( "step" ) |
|||
{ |
|||
m_argParser.add_argument( ARG_DRILL_ORIGIN ) |
|||
.help( "Use Drill Origin for output origin" ) |
|||
.implicit_value( true ) |
|||
.default_value( false ); |
|||
|
|||
m_argParser.add_argument( ARG_GRID_ORIGIN ) |
|||
.help( "Use Grid Origin for output origin" ) |
|||
.implicit_value( true ) |
|||
.default_value( false ); |
|||
|
|||
m_argParser.add_argument( ARG_NO_VIRTUAL ) |
|||
.help( "Exclude 3D models for components with 'virtual' attribute" ) |
|||
.implicit_value( true ) |
|||
.default_value( false ); |
|||
|
|||
m_argParser.add_argument( "--subst-models" ) |
|||
.help( "Substitute STEP or IGS models with the same name in place of VRML models" ) |
|||
.implicit_value( true ) |
|||
.default_value( false ); |
|||
|
|||
m_argParser.add_argument( ARG_FORCE, "-f" ) |
|||
.help( "overwrite output file" ) |
|||
.implicit_value( true ) |
|||
.default_value( false ); |
|||
|
|||
m_argParser.add_argument( ARG_GUI ) |
|||
.help( "Show GUI (log window)" ) |
|||
.implicit_value( true ) |
|||
.default_value( false ); |
|||
|
|||
m_argParser.add_argument( ARG_MIN_DISTANCE ) |
|||
.default_value( std::string() ) |
|||
.help( "Minimum distance between points to treat them as separate ones (default 0.01mm)" ); |
|||
|
|||
m_argParser.add_argument( ARG_USER_ORIGIN ) |
|||
.default_value( std::string() ) |
|||
.help( "User-specified output origin ex. 1x1in, 1x1inch, 25.4x25.4mm (default mm)" ); |
|||
|
|||
m_argParser.add_argument( "-o", ARG_OUTPUT ) |
|||
.default_value( std::string() ) |
|||
.help( "output file name" ); |
|||
|
|||
m_argParser.add_argument( ARG_INPUT ).help( "input file" ); |
|||
} |
|||
|
|||
int CLI::EXPORT_STEP_COMMAND::Perform( KIWAY& aKiway ) const |
|||
{ |
|||
JOB_EXPORT_STEP* step = new JOB_EXPORT_STEP( true ); |
|||
|
|||
step->m_useDrillOrigin = m_argParser.get<bool>( ARG_DRILL_ORIGIN ); |
|||
step->m_useGridOrigin = m_argParser.get<bool>( ARG_GRID_ORIGIN ); |
|||
step->m_includeVirtual = !m_argParser.get<bool>( ARG_NO_VIRTUAL ); |
|||
step->m_substModels = m_argParser.get<bool>( ARG_SUBST_MODELS ); |
|||
step->m_overwrite = m_argParser.get<bool>( ARG_FORCE ); |
|||
step->m_filename = FROM_UTF8( m_argParser.get<std::string>( ARG_INPUT ).c_str() ); |
|||
step->m_outputFile = FROM_UTF8( m_argParser.get<std::string>( ARG_OUTPUT ).c_str() ); |
|||
step->m_gui = m_argParser.get<bool>( ARG_GUI ); |
|||
|
|||
wxString userOrigin = FROM_UTF8( m_argParser.get<std::string>( ARG_USER_ORIGIN ).c_str() ); |
|||
if( !userOrigin.IsEmpty() ) |
|||
{ |
|||
std::regex re_pattern( REGEX_QUANTITY REGEX_DELIMITER REGEX_QUANTITY REGEX_UNIT, |
|||
std::regex_constants::icase ); |
|||
std::smatch sm; |
|||
std::string str( userOrigin.ToUTF8() ); |
|||
std::regex_search( str, sm, re_pattern ); |
|||
step->m_xOrigin = atof( sm.str( 1 ).c_str() ); |
|||
step->m_yOrigin = atof( sm.str( 2 ).c_str() ); |
|||
|
|||
std::string tunit( sm[3] ); |
|||
|
|||
if( tunit.size() > 0 ) // No unit accepted ( default = mm )
|
|||
{ |
|||
if( ( !sm.str( 1 ).compare( " " ) || !sm.str( 2 ).compare( " " ) ) |
|||
|| ( sm.size() != 4 ) ) |
|||
{ |
|||
std::cout << m_argParser; |
|||
return CLI::EXIT_CODES::ERR_ARGS; |
|||
} |
|||
|
|||
// only in, inch and mm are valid:
|
|||
if( !tunit.compare( "in" ) || !tunit.compare( "inch" ) ) |
|||
{ |
|||
step->m_xOrigin *= 25.4; |
|||
step->m_yOrigin *= 25.4; |
|||
} |
|||
else if( tunit.compare( "mm" ) ) |
|||
{ |
|||
std::cout << m_argParser; |
|||
return CLI::EXIT_CODES::ERR_ARGS; |
|||
} |
|||
} |
|||
} |
|||
|
|||
wxString minDistance = FROM_UTF8( m_argParser.get<std::string>( ARG_MIN_DISTANCE ).c_str() ); |
|||
if( !minDistance.IsEmpty() ) |
|||
{ |
|||
std::istringstream istr; |
|||
istr.str( std::string( minDistance.ToUTF8() ) ); |
|||
istr >> step->m_minDistance; |
|||
|
|||
if( istr.fail() ) |
|||
{ |
|||
std::cout << m_argParser; |
|||
return CLI::EXIT_CODES::ERR_ARGS; |
|||
} |
|||
|
|||
if( !istr.eof() ) |
|||
{ |
|||
std::string tunit; |
|||
istr >> tunit; |
|||
|
|||
if( !tunit.compare( "in" ) || !tunit.compare( "inch" ) ) |
|||
{ |
|||
step->m_minDistance *= 25.4; |
|||
} |
|||
else if( tunit.compare( "mm" ) ) |
|||
{ |
|||
std::cout << m_argParser; |
|||
return CLI::EXIT_CODES::ERR_ARGS; |
|||
} |
|||
} |
|||
} |
|||
|
|||
int exitCode = aKiway.ProcessJob( KIWAY::FACE_PCB, step ); |
|||
|
|||
return exitCode; |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com> |
|||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* 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 <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef COMMAND_EXPORT_STEP_H |
|||
#define COMMAND_EXPORT_STEP_H |
|||
|
|||
#include "command.h" |
|||
|
|||
namespace CLI |
|||
{ |
|||
struct EXPORT_STEP_COMMAND : public COMMAND |
|||
{ |
|||
EXPORT_STEP_COMMAND(); |
|||
|
|||
int Perform( KIWAY& aKiway ) const override; |
|||
}; |
|||
} |
|||
|
|||
#endif |
|||
@ -0,0 +1,38 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com> |
|||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* 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 <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef CLI_EXIT_CODES_H |
|||
#define CLI_EXIT_CODES_H |
|||
|
|||
namespace CLI |
|||
{ |
|||
namespace EXIT_CODES |
|||
{ |
|||
static const int AVOID_CLOSING = -1; |
|||
static const int SUCCESS = 0; |
|||
static const int OK = 0; |
|||
static const int ERR_ARGS = 1; |
|||
static const int ERR_UNKNOWN = 2; |
|||
static const int ERR_INVALID_INPUT_FILE = 3; |
|||
static const int ERR_INVALID_OUTPUT_CONFLICT = 4; |
|||
}; |
|||
} |
|||
|
|||
#endif |
|||
@ -0,0 +1,42 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com> |
|||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* 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 <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef JOB_H |
|||
#define JOB_H |
|||
|
|||
/** |
|||
* An simple container class that lets us dispatch output jobs to kifaces |
|||
*/ |
|||
class JOB |
|||
{ |
|||
public: |
|||
JOB( const std::string& aType, bool aIsCli ) : m_type( aType ), m_isCli( aIsCli ) {} |
|||
|
|||
virtual ~JOB() {} |
|||
|
|||
const std::string& GetType() const { return m_type; }; |
|||
bool IsCli() const { return m_isCli; }; |
|||
|
|||
private: |
|||
std::string m_type; |
|||
bool m_isCli; |
|||
}; |
|||
|
|||
#endif |
|||
@ -0,0 +1,38 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com> |
|||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* 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 <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
#include <cli/exit_codes.h>
|
|||
#include <jobs/job_dispatcher.h>
|
|||
|
|||
void JOB_DISPATCHER::Register( const std::string& aJobTypeName, |
|||
std::function<int( JOB* job )> aHandler ) |
|||
{ |
|||
m_jobHandlers.emplace( aJobTypeName, aHandler ); |
|||
} |
|||
|
|||
int JOB_DISPATCHER::RunJob( JOB* job ) |
|||
{ |
|||
if( m_jobHandlers.count( job->GetType() ) ) |
|||
{ |
|||
return m_jobHandlers[job->GetType()]( job ); |
|||
} |
|||
|
|||
return CLI::EXIT_CODES::ERR_UNKNOWN; |
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com> |
|||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* 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 <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef JOB_DISPATCHER_H |
|||
#define JOB_DISPATCHER_H |
|||
|
|||
#include <functional> |
|||
#include <string> |
|||
#include <map> |
|||
#include <jobs/job.h> |
|||
|
|||
class JOB_DISPATCHER |
|||
{ |
|||
public: |
|||
void Register( const std::string& aJobTypeName, std::function<int( JOB* job )> aHandler ); |
|||
int RunJob( JOB* job ); |
|||
|
|||
private: |
|||
std::map<std::string, std::function<int( JOB* job )>> m_jobHandlers; |
|||
}; |
|||
|
|||
#endif |
|||
@ -0,0 +1,49 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com> |
|||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* 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 <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef JOB_EXPORT_PCB_SVG_H |
|||
#define JOB_EXPORT_PCB_SVG_H |
|||
|
|||
#include <layer_ids.h> |
|||
#include <wx/string.h> |
|||
#include "job.h" |
|||
|
|||
class JOB_EXPORT_PCB_SVG : public JOB |
|||
{ |
|||
public: |
|||
JOB_EXPORT_PCB_SVG( bool aIsCli ) : |
|||
JOB( "svg", aIsCli ), m_filename(), m_outputFile(), m_colorTheme(), m_mirror( false ), |
|||
m_blackAndWhite( false ), m_pageSizeMode( 0 ), m_printMaskLayer() |
|||
{ |
|||
} |
|||
|
|||
wxString m_filename; |
|||
wxString m_outputFile; |
|||
wxString m_colorTheme; |
|||
|
|||
bool m_mirror; |
|||
bool m_blackAndWhite; |
|||
|
|||
int m_pageSizeMode; |
|||
|
|||
LSET m_printMaskLayer; |
|||
}; |
|||
|
|||
#endif |
|||
@ -0,0 +1,34 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com> |
|||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* 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 <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
#include "jobs/job_export_step.h"
|
|||
|
|||
JOB_EXPORT_STEP::JOB_EXPORT_STEP( bool aIsCli ) : JOB( "step", aIsCli ) |
|||
{ |
|||
m_overwrite = false; |
|||
m_useGridOrigin = false; |
|||
m_useDrillOrigin = false; |
|||
m_includeVirtual = true; |
|||
m_substModels = false; |
|||
m_xOrigin = 0.0; |
|||
m_yOrigin = 0.0; |
|||
m_minDistance = 0.0; |
|||
m_gui = false; |
|||
} |
|||
@ -0,0 +1,45 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com> |
|||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* 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 <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef JOB_EXPORT_STEP_H |
|||
#define JOB_EXPORT_STEP_H |
|||
|
|||
#include <wx/string.h> |
|||
#include "job.h" |
|||
|
|||
class JOB_EXPORT_STEP : public JOB |
|||
{ |
|||
public: |
|||
JOB_EXPORT_STEP( bool aIsCli ); |
|||
|
|||
bool m_overwrite; |
|||
bool m_useGridOrigin; |
|||
bool m_useDrillOrigin; |
|||
bool m_includeVirtual; |
|||
bool m_substModels; |
|||
wxString m_filename; |
|||
wxString m_outputFile; |
|||
double m_xOrigin; |
|||
double m_yOrigin; |
|||
double m_minDistance; |
|||
bool m_gui; |
|||
}; |
|||
|
|||
#endif |
|||
@ -0,0 +1,106 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr |
|||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* 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 <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
#include <board.h>
|
|||
#include <board_design_settings.h>
|
|||
#include <locale_io.h>
|
|||
#include <pcbnew_settings.h>
|
|||
#include <pcb_plot_params.h>
|
|||
#include <pcb_plot_svg.h>
|
|||
#include <pcbplot.h>
|
|||
#include <pgm_base.h>
|
|||
#include <plotters/plotters_pslike.h>
|
|||
|
|||
|
|||
bool PCB_PLOT_SVG::Plot( BOARD* aBoard, const PCB_PLOT_SVG_OPTIONS& aSvgPlotOptions ) |
|||
{ |
|||
PCB_PLOT_PARAMS plot_opts; |
|||
|
|||
plot_opts.SetPlotFrameRef( aSvgPlotOptions.m_pageSizeMode ); |
|||
|
|||
// Adding drill marks, for copper layers
|
|||
if( ( aSvgPlotOptions.m_printMaskLayer & LSET::AllCuMask() ).any() ) |
|||
plot_opts.SetDrillMarksType( PCB_PLOT_PARAMS::FULL_DRILL_SHAPE ); |
|||
else |
|||
plot_opts.SetDrillMarksType( PCB_PLOT_PARAMS::NO_DRILL_SHAPE ); |
|||
|
|||
plot_opts.SetSkipPlotNPTH_Pads( false ); |
|||
|
|||
plot_opts.SetMirror( aSvgPlotOptions.m_mirror ); |
|||
plot_opts.SetFormat( PLOT_FORMAT::SVG ); |
|||
// coord format: 4 digits in mantissa (units always in mm). This is a good choice.
|
|||
plot_opts.SetSvgPrecision( 4 ); |
|||
|
|||
PAGE_INFO savedPageInfo = aBoard->GetPageSettings(); |
|||
VECTOR2I savedAuxOrigin = aBoard->GetDesignSettings().GetAuxOrigin(); |
|||
|
|||
if( aSvgPlotOptions.m_pageSizeMode == 2 ) // Page is board boundary size
|
|||
{ |
|||
BOX2I bbox = aBoard->ComputeBoundingBox(); |
|||
PAGE_INFO currpageInfo = aBoard->GetPageSettings(); |
|||
|
|||
currpageInfo.SetWidthMils( bbox.GetWidth() / pcbIUScale.IU_PER_MILS ); |
|||
currpageInfo.SetHeightMils( bbox.GetHeight() / pcbIUScale.IU_PER_MILS ); |
|||
aBoard->SetPageSettings( currpageInfo ); |
|||
plot_opts.SetUseAuxOrigin( true ); |
|||
VECTOR2I origin = bbox.GetOrigin(); |
|||
aBoard->GetDesignSettings().SetAuxOrigin( origin ); |
|||
} |
|||
|
|||
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); |
|||
PCBNEW_SETTINGS* cfg = mgr.GetAppSettings<PCBNEW_SETTINGS>(); |
|||
|
|||
plot_opts.SetColorSettings( mgr.GetColorSettings( cfg->m_ColorTheme ) ); |
|||
|
|||
COLOR_SETTINGS* theme = nullptr; |
|||
if( !aSvgPlotOptions.m_colorTheme.IsEmpty() ) |
|||
{ |
|||
theme = mgr.GetColorSettings( aSvgPlotOptions.m_colorTheme ); |
|||
} |
|||
|
|||
if( !theme ) |
|||
{ |
|||
theme = mgr.GetColorSettings( cfg->m_ColorTheme ); |
|||
} |
|||
|
|||
LOCALE_IO toggle; |
|||
|
|||
//@todo allow controlling the sheet name and path that will be displayed in the title block
|
|||
// Leave blank for now
|
|||
SVG_PLOTTER* plotter = (SVG_PLOTTER*) StartPlotBoard( aBoard, &plot_opts, UNDEFINED_LAYER, |
|||
aSvgPlotOptions.m_outputFile, |
|||
wxEmptyString, wxEmptyString ); |
|||
|
|||
if( plotter ) |
|||
{ |
|||
plotter->SetColorMode( !aSvgPlotOptions.m_blackAndWhite ); |
|||
PlotBoardLayers( aBoard, plotter, aSvgPlotOptions.m_printMaskLayer.SeqStackupBottom2Top(), |
|||
plot_opts ); |
|||
plotter->EndPlot(); |
|||
} |
|||
|
|||
delete plotter; |
|||
|
|||
// reset to the values saved earlier
|
|||
aBoard->GetDesignSettings().SetAuxOrigin( savedAuxOrigin ); |
|||
aBoard->SetPageSettings( savedPageInfo ); |
|||
|
|||
return true; |
|||
} |
|||
@ -0,0 +1,43 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr |
|||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* 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 <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef PCB_PLOT_SVG_H |
|||
#define PCB_PLOT_SVG_H |
|||
|
|||
struct PCB_PLOT_SVG_OPTIONS |
|||
{ |
|||
wxString m_outputFile; |
|||
wxString m_colorTheme; |
|||
|
|||
bool m_mirror; |
|||
bool m_blackAndWhite; |
|||
|
|||
int m_pageSizeMode; |
|||
|
|||
LSET m_printMaskLayer; |
|||
}; |
|||
|
|||
class PCB_PLOT_SVG |
|||
{ |
|||
public: |
|||
static bool Plot( BOARD* aBoard, const PCB_PLOT_SVG_OPTIONS& aSvgPlotOptions ); |
|||
}; |
|||
|
|||
#endif |
|||
@ -0,0 +1,102 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com> |
|||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* 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 <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
#include "pcbnew_jobs_handler.h"
|
|||
#include <kicad2step.h>
|
|||
#include <jobs/job_export_pcb_svg.h>
|
|||
#include <jobs/job_export_step.h>
|
|||
#include <cli/exit_codes.h>
|
|||
#include <plotters/plotters_pslike.h>
|
|||
#include <pgm_base.h>
|
|||
#include <pcbplot.h>
|
|||
#include <board_design_settings.h>
|
|||
#include <pcbnew_settings.h>
|
|||
#include <wx/crt.h>
|
|||
#include <pcb_plot_svg.h>
|
|||
|
|||
#include "pcbnew_scripting_helpers.h"
|
|||
|
|||
PCBNEW_JOBS_HANDLER::PCBNEW_JOBS_HANDLER() |
|||
{ |
|||
Register( "step", |
|||
std::bind( &PCBNEW_JOBS_HANDLER::JobExportStep, this, std::placeholders::_1 ) ); |
|||
Register( "svg", |
|||
std::bind( &PCBNEW_JOBS_HANDLER::JobExportSvg, this, std::placeholders::_1 ) ); |
|||
} |
|||
|
|||
|
|||
int PCBNEW_JOBS_HANDLER::JobExportStep( JOB* aJob ) |
|||
{ |
|||
JOB_EXPORT_STEP* aStepJob = dynamic_cast<JOB_EXPORT_STEP*>( aJob ); |
|||
|
|||
if( aStepJob == nullptr ) |
|||
return CLI::EXIT_CODES::ERR_UNKNOWN; |
|||
|
|||
KICAD2MCAD_PRMS params; |
|||
params.m_useDrillOrigin = aStepJob->m_useDrillOrigin; |
|||
params.m_useGridOrigin = aStepJob->m_useGridOrigin; |
|||
params.m_overwrite = aStepJob->m_overwrite; |
|||
params.m_includeVirtual = aStepJob->m_includeVirtual; |
|||
params.m_filename = aStepJob->m_filename; |
|||
params.m_outputFile = aStepJob->m_outputFile; |
|||
params.m_xOrigin = aStepJob->m_xOrigin; |
|||
params.m_yOrigin = aStepJob->m_yOrigin; |
|||
params.m_minDistance = aStepJob->m_minDistance; |
|||
params.m_substModels = aStepJob->m_substModels; |
|||
params.m_gui = aStepJob->m_gui; |
|||
|
|||
// we might need the lifetime of the converter to continue until frame destruction
|
|||
// due to the gui parameter
|
|||
KICAD2STEP* converter = new KICAD2STEP( params ); |
|||
|
|||
return converter->Run(); |
|||
} |
|||
|
|||
|
|||
int PCBNEW_JOBS_HANDLER::JobExportSvg( JOB* aJob ) |
|||
{ |
|||
JOB_EXPORT_PCB_SVG* aSvgJob = dynamic_cast<JOB_EXPORT_PCB_SVG*>( aJob ); |
|||
|
|||
if( aSvgJob == nullptr ) |
|||
return CLI::EXIT_CODES::ERR_UNKNOWN; |
|||
|
|||
PCB_PLOT_SVG_OPTIONS svgPlotOptions; |
|||
svgPlotOptions.m_blackAndWhite = aSvgJob->m_blackAndWhite; |
|||
svgPlotOptions.m_colorTheme = aSvgJob->m_colorTheme; |
|||
svgPlotOptions.m_outputFile = aSvgJob->m_outputFile; |
|||
svgPlotOptions.m_mirror = aSvgJob->m_mirror; |
|||
svgPlotOptions.m_pageSizeMode = aSvgJob->m_pageSizeMode; |
|||
svgPlotOptions.m_printMaskLayer = aSvgJob->m_printMaskLayer; |
|||
|
|||
if( aJob->IsCli() ) |
|||
wxPrintf( _( "Loading board\n" ) ); |
|||
|
|||
BOARD* brd = LoadBoard( aSvgJob->m_filename ); |
|||
|
|||
if( aJob->IsCli() ) |
|||
{ |
|||
if( PCB_PLOT_SVG::Plot( brd, svgPlotOptions ) ) |
|||
wxPrintf( _( "Successfully created svg file" ) ); |
|||
else |
|||
wxPrintf( _( "Error creating svg file" ) ); |
|||
} |
|||
|
|||
return CLI::EXIT_CODES::OK; |
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com> |
|||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* 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 <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef PCBNEW_JOBS_HANDLER_H |
|||
#define PCBNEW_JOBS_HANDLER_H |
|||
|
|||
#include <jobs/job_dispatcher.h> |
|||
|
|||
class PCBNEW_JOBS_HANDLER : public JOB_DISPATCHER |
|||
{ |
|||
public: |
|||
PCBNEW_JOBS_HANDLER(); |
|||
int JobExportStep( JOB* aJob ); |
|||
int JobExportSvg( JOB* aJob ); |
|||
}; |
|||
|
|||
#endif |
|||
@ -0,0 +1 @@ |
|||
@"%~dp0kicad.exe" %* |
|||
@ -0,0 +1 @@ |
|||
@"%~dp0pcbnew.exe" %* |
|||
@ -0,0 +1,117 @@ |
|||
--- |
|||
Language: Cpp |
|||
# BasedOnStyle: LLVM |
|||
AccessModifierOffset: -2 |
|||
AlignAfterOpenBracket: Align |
|||
AlignConsecutiveAssignments: false |
|||
AlignConsecutiveDeclarations: false |
|||
AlignEscapedNewlines: Right |
|||
AlignOperands: true |
|||
AlignTrailingComments: true |
|||
AllowAllParametersOfDeclarationOnNextLine: true |
|||
AllowShortBlocksOnASingleLine: false |
|||
AllowShortCaseLabelsOnASingleLine: false |
|||
AllowShortFunctionsOnASingleLine: All |
|||
AllowShortIfStatementsOnASingleLine: false |
|||
AllowShortLoopsOnASingleLine: false |
|||
AlwaysBreakAfterDefinitionReturnType: None |
|||
AlwaysBreakAfterReturnType: None |
|||
AlwaysBreakBeforeMultilineStrings: false |
|||
AlwaysBreakTemplateDeclarations: false |
|||
BinPackArguments: true |
|||
BinPackParameters: true |
|||
BraceWrapping: |
|||
AfterClass: false |
|||
AfterControlStatement: false |
|||
AfterEnum: false |
|||
AfterFunction: false |
|||
AfterNamespace: false |
|||
AfterObjCDeclaration: false |
|||
AfterStruct: false |
|||
AfterUnion: false |
|||
AfterExternBlock: false |
|||
BeforeCatch: false |
|||
BeforeElse: false |
|||
IndentBraces: false |
|||
SplitEmptyFunction: true |
|||
SplitEmptyRecord: true |
|||
SplitEmptyNamespace: true |
|||
BreakBeforeBinaryOperators: None |
|||
BreakBeforeBraces: Attach |
|||
BreakBeforeInheritanceComma: false |
|||
BreakBeforeTernaryOperators: true |
|||
BreakConstructorInitializersBeforeComma: false |
|||
BreakConstructorInitializers: BeforeColon |
|||
BreakAfterJavaFieldAnnotations: false |
|||
BreakStringLiterals: true |
|||
ColumnLimit: 80 |
|||
CommentPragmas: '^ IWYU pragma:' |
|||
CompactNamespaces: false |
|||
ConstructorInitializerAllOnOneLineOrOnePerLine: false |
|||
ConstructorInitializerIndentWidth: 4 |
|||
ContinuationIndentWidth: 4 |
|||
Cpp11BracedListStyle: true |
|||
DerivePointerAlignment: false |
|||
DisableFormat: false |
|||
ExperimentalAutoDetectBinPacking: false |
|||
FixNamespaceComments: true |
|||
ForEachMacros: |
|||
- foreach |
|||
- Q_FOREACH |
|||
- BOOST_FOREACH |
|||
IncludeBlocks: Preserve |
|||
IncludeCategories: |
|||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/' |
|||
Priority: 2 |
|||
- Regex: '^(<|"(gtest|gmock|isl|json)/)' |
|||
Priority: 3 |
|||
- Regex: '.*' |
|||
Priority: 1 |
|||
IncludeIsMainRegex: '(Test)?$' |
|||
IndentCaseLabels: false |
|||
IndentPPDirectives: None |
|||
IndentWidth: 2 |
|||
IndentWrappedFunctionNames: false |
|||
JavaScriptQuotes: Leave |
|||
JavaScriptWrapImports: true |
|||
KeepEmptyLinesAtTheStartOfBlocks: true |
|||
MacroBlockBegin: '' |
|||
MacroBlockEnd: '' |
|||
MaxEmptyLinesToKeep: 1 |
|||
NamespaceIndentation: None |
|||
ObjCBlockIndentWidth: 2 |
|||
ObjCSpaceAfterProperty: false |
|||
ObjCSpaceBeforeProtocolList: true |
|||
PenaltyBreakAssignment: 2 |
|||
PenaltyBreakBeforeFirstCallParameter: 19 |
|||
PenaltyBreakComment: 300 |
|||
PenaltyBreakFirstLessLess: 120 |
|||
PenaltyBreakString: 1000 |
|||
PenaltyExcessCharacter: 1000000 |
|||
PenaltyReturnTypeOnItsOwnLine: 60 |
|||
PointerAlignment: Right |
|||
RawStringFormats: |
|||
- Language: TextProto |
|||
Delimiters: |
|||
- 'pb' |
|||
- 'proto' |
|||
BasedOnStyle: google |
|||
ReflowComments: true |
|||
SortIncludes: true |
|||
SortUsingDeclarations: true |
|||
SpaceAfterCStyleCast: false |
|||
SpaceAfterTemplateKeyword: true |
|||
SpaceBeforeAssignmentOperators: true |
|||
SpaceBeforeParens: ControlStatements |
|||
SpaceInEmptyParentheses: false |
|||
SpacesBeforeTrailingComments: 1 |
|||
SpacesInAngles: false |
|||
SpacesInContainerLiterals: true |
|||
SpacesInCStyleCastParentheses: false |
|||
SpacesInParentheses: false |
|||
SpacesInSquareBrackets: false |
|||
Standard: c++17 |
|||
TabWidth: 8 |
|||
UseTab: Never |
|||
... |
|||
|
|||
@ -0,0 +1,21 @@ |
|||
Checks: |
|||
-*, |
|||
clang-analyzer-*, |
|||
cppcoreguidelines-avoid-c-arrays, |
|||
cppcoreguidelines-special-member-functions, |
|||
readability-*, |
|||
|
|||
CheckOptions: |
|||
- { key: readability-identifier-naming.ClassCase, value: CamelCase } |
|||
- { key: readability-identifier-naming.ConstexprVariableCase, value: lower_case } |
|||
- { key: readability-identifier-naming.ConstexprVariableIgnoredRegexp, value: "^Is.+" } |
|||
- { key: readability-identifier-naming.FunctionCase, value: lower_case } |
|||
- { key: readability-identifier-naming.NamespaceCase, value: lower_case } |
|||
- { key: readability-identifier-naming.ParameterCase, value: lower_case } |
|||
- { key: readability-identifier-naming.PrivateMemberCase, value: lower_case } |
|||
- { key: readability-identifier-naming.PrivateMemberPrefix, value: m_ } |
|||
- { key: readability-identifier-naming.StructCase, value: CamelCase } |
|||
- { key: readability-identifier-naming.StructIgnoredRegexp, value: "parse_number" } |
|||
- { key: readability-identifier-naming.VariableCase, value: lower_case } |
|||
|
|||
HeaderFilterRegex: '.*' |
|||
@ -0,0 +1,87 @@ |
|||
|
|||
name: CI |
|||
|
|||
on: pull_request |
|||
|
|||
jobs: |
|||
|
|||
test: |
|||
|
|||
name: ${{ matrix.toolchain }} |
|||
runs-on: ${{ matrix.os }} |
|||
|
|||
strategy: |
|||
|
|||
matrix: |
|||
|
|||
toolchain: |
|||
- macos-latest-clang |
|||
- macos-12-clang |
|||
- ubuntu-latest-clang |
|||
- ubuntu-latest-gcc |
|||
- windows-2019-msvc |
|||
- windows-latest-msvc |
|||
- windows-latest-clang |
|||
|
|||
include: |
|||
- toolchain: macos-latest-clang |
|||
os: macos-latest |
|||
c_compiler: clang |
|||
cxx_compiler: clang++ |
|||
|
|||
- toolchain: macos-12-clang |
|||
os: macos-latest |
|||
c_compiler: clang |
|||
cxx_compiler: clang++ |
|||
|
|||
- toolchain: ubuntu-latest-clang |
|||
os: ubuntu-latest |
|||
c_compiler: clang |
|||
cxx_compiler: clang++ |
|||
|
|||
- toolchain: ubuntu-latest-gcc |
|||
os: ubuntu-latest |
|||
c_compiler: cc |
|||
cxx_compiler: g++ |
|||
|
|||
- toolchain: windows-2019-msvc |
|||
os: windows-2019 |
|||
c_compiler: msvc |
|||
cxx_compiler: msvc |
|||
|
|||
- toolchain: windows-latest-msvc |
|||
os: windows-latest |
|||
c_compiler: msvc |
|||
cxx_compiler: msvc |
|||
|
|||
- toolchain: windows-latest-clang |
|||
os: windows-latest |
|||
c_compiler: clang-cl |
|||
cxx_compiler: clang-cl |
|||
cmake_opts: -T ClangCL |
|||
|
|||
steps: |
|||
|
|||
- name: Checkout Code |
|||
uses: actions/checkout@v2 |
|||
|
|||
- name: Configure |
|||
working-directory: test |
|||
run: cmake -S . -B build ${{ matrix.cmake_opts }} |
|||
env: |
|||
CC: ${{ matrix.c_compiler }} |
|||
CXX: ${{ matrix.cxx_compiler }} |
|||
|
|||
- name: Build for ${{ matrix.os }} with ${{ matrix.compiler }} |
|||
working-directory: test |
|||
run: cmake --build build |
|||
|
|||
- name: Test |
|||
if: ${{ ! startsWith(matrix.os, 'windows') }} |
|||
working-directory: test/build |
|||
run: ./tests |
|||
|
|||
- name: Test (Windows) |
|||
if: ${{ startsWith(matrix.os, 'windows') }} |
|||
working-directory: test/build |
|||
run: ./Debug/tests.exe |
|||
@ -0,0 +1,273 @@ |
|||
## Ignore Visual Studio temporary files, build results, and |
|||
## files generated by popular Visual Studio add-ons. |
|||
|
|||
# User-specific files |
|||
*.suo |
|||
*.user |
|||
*.userosscache |
|||
*.sln.docstates |
|||
|
|||
# User-specific files (MonoDevelop/Xamarin Studio) |
|||
*.userprefs |
|||
|
|||
# Build results |
|||
[Dd]ebug/ |
|||
[Dd]ebugPublic/ |
|||
[Rr]elease/ |
|||
[Rr]eleases/ |
|||
x64/ |
|||
x86/ |
|||
bld/ |
|||
[Bb]in/ |
|||
[Oo]bj/ |
|||
[Ll]og/ |
|||
|
|||
# Visual Studio 2015 cache/options directory |
|||
.vs/ |
|||
.vscode/ |
|||
# Uncomment if you have tasks that create the project's static files in wwwroot |
|||
#wwwroot/ |
|||
|
|||
# MSTest test Results |
|||
[Tt]est[Rr]esult*/ |
|||
[Bb]uild[Ll]og.* |
|||
|
|||
# NUNIT |
|||
*.VisualState.xml |
|||
TestResult.xml |
|||
|
|||
# Build Results of an ATL Project |
|||
[Dd]ebugPS/ |
|||
[Rr]eleasePS/ |
|||
dlldata.c |
|||
|
|||
# DNX |
|||
project.lock.json |
|||
project.fragment.lock.json |
|||
artifacts/ |
|||
|
|||
*_i.c |
|||
*_p.c |
|||
*_i.h |
|||
*.ilk |
|||
*.meta |
|||
*.obj |
|||
*.pch |
|||
*.pdb |
|||
*.pgc |
|||
*.pgd |
|||
*.rsp |
|||
*.sbr |
|||
*.tlb |
|||
*.tli |
|||
*.tlh |
|||
*.tmp |
|||
*.tmp_proj |
|||
*.log |
|||
*.vspscc |
|||
*.vssscc |
|||
.builds |
|||
*.pidb |
|||
*.svclog |
|||
*.scc |
|||
|
|||
# Chutzpah Test files |
|||
_Chutzpah* |
|||
|
|||
# Visual C++ cache files |
|||
ipch/ |
|||
*.aps |
|||
*.ncb |
|||
*.opendb |
|||
*.opensdf |
|||
*.sdf |
|||
*.cachefile |
|||
*.VC.db |
|||
*.VC.VC.opendb |
|||
|
|||
# Visual Studio profiler |
|||
*.psess |
|||
*.vsp |
|||
*.vspx |
|||
*.sap |
|||
|
|||
# TFS 2012 Local Workspace |
|||
$tf/ |
|||
|
|||
# Guidance Automation Toolkit |
|||
*.gpState |
|||
|
|||
# ReSharper is a .NET coding add-in |
|||
_ReSharper*/ |
|||
*.[Rr]e[Ss]harper |
|||
*.DotSettings.user |
|||
|
|||
# JustCode is a .NET coding add-in |
|||
.JustCode |
|||
|
|||
# TeamCity is a build add-in |
|||
_TeamCity* |
|||
|
|||
# DotCover is a Code Coverage Tool |
|||
*.dotCover |
|||
|
|||
# NCrunch |
|||
_NCrunch_* |
|||
.*crunch*.local.xml |
|||
nCrunchTemp_* |
|||
|
|||
# MightyMoose |
|||
*.mm.* |
|||
AutoTest.Net/ |
|||
|
|||
# Web workbench (sass) |
|||
.sass-cache/ |
|||
|
|||
# Installshield output folder |
|||
[Ee]xpress/ |
|||
|
|||
# DocProject is a documentation generator add-in |
|||
DocProject/buildhelp/ |
|||
DocProject/Help/*.HxT |
|||
DocProject/Help/*.HxC |
|||
DocProject/Help/*.hhc |
|||
DocProject/Help/*.hhk |
|||
DocProject/Help/*.hhp |
|||
DocProject/Help/Html2 |
|||
DocProject/Help/html |
|||
|
|||
# Click-Once directory |
|||
publish/ |
|||
|
|||
# Publish Web Output |
|||
*.[Pp]ublish.xml |
|||
*.azurePubxml |
|||
# TODO: Comment the next line if you want to checkin your web deploy settings |
|||
# but database connection strings (with potential passwords) will be unencrypted |
|||
#*.pubxml |
|||
*.publishproj |
|||
|
|||
# Microsoft Azure Web App publish settings. Comment the next line if you want to |
|||
# checkin your Azure Web App publish settings, but sensitive information contained |
|||
# in these scripts will be unencrypted |
|||
PublishScripts/ |
|||
|
|||
# NuGet Packages |
|||
*.nupkg |
|||
# The packages folder can be ignored because of Package Restore |
|||
**/packages/* |
|||
# except build/, which is used as an MSBuild target. |
|||
!**/packages/build/ |
|||
# Uncomment if necessary however generally it will be regenerated when needed |
|||
#!**/packages/repositories.config |
|||
# NuGet v3's project.json files produces more ignoreable files |
|||
*.nuget.props |
|||
*.nuget.targets |
|||
|
|||
# Microsoft Azure Build Output |
|||
csx/ |
|||
*.build.csdef |
|||
|
|||
# Microsoft Azure Emulator |
|||
ecf/ |
|||
rcf/ |
|||
|
|||
# Windows Store app package directories and files |
|||
AppPackages/ |
|||
BundleArtifacts/ |
|||
Package.StoreAssociation.xml |
|||
_pkginfo.txt |
|||
|
|||
# Visual Studio cache files |
|||
# files ending in .cache can be ignored |
|||
*.[Cc]ache |
|||
# but keep track of directories ending in .cache |
|||
!*.[Cc]ache/ |
|||
|
|||
# Others |
|||
ClientBin/ |
|||
~$* |
|||
*~ |
|||
*.dbmdl |
|||
*.dbproj.schemaview |
|||
*.jfm |
|||
*.pfx |
|||
*.publishsettings |
|||
node_modules/ |
|||
orleans.codegen.cs |
|||
|
|||
# Since there are multiple workflows, uncomment next line to ignore bower_components |
|||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) |
|||
#bower_components/ |
|||
|
|||
# RIA/Silverlight projects |
|||
Generated_Code/ |
|||
|
|||
# Backup & report files from converting an old project file |
|||
# to a newer Visual Studio version. Backup files are not needed, |
|||
# because we have git ;-) |
|||
_UpgradeReport_Files/ |
|||
Backup*/ |
|||
UpgradeLog*.XML |
|||
UpgradeLog*.htm |
|||
|
|||
# SQL Server files |
|||
*.mdf |
|||
*.ldf |
|||
|
|||
# Business Intelligence projects |
|||
*.rdl.data |
|||
*.bim.layout |
|||
*.bim_*.settings |
|||
|
|||
# Microsoft Fakes |
|||
FakesAssemblies/ |
|||
|
|||
# GhostDoc plugin setting file |
|||
*.GhostDoc.xml |
|||
|
|||
# Node.js Tools for Visual Studio |
|||
.ntvs_analysis.dat |
|||
|
|||
# Visual Studio 6 build log |
|||
*.plg |
|||
|
|||
# Visual Studio 6 workspace options file |
|||
*.opt |
|||
|
|||
# Visual Studio LightSwitch build output |
|||
**/*.HTMLClient/GeneratedArtifacts |
|||
**/*.DesktopClient/GeneratedArtifacts |
|||
**/*.DesktopClient/ModelManifest.xml |
|||
**/*.Server/GeneratedArtifacts |
|||
**/*.Server/ModelManifest.xml |
|||
_Pvt_Extensions |
|||
|
|||
# Paket dependency manager |
|||
.paket/paket.exe |
|||
paket-files/ |
|||
|
|||
# FAKE - F# Make |
|||
.fake/ |
|||
|
|||
# JetBrains Rider |
|||
.idea/ |
|||
*.sln.iml |
|||
|
|||
# CodeRush |
|||
.cr/ |
|||
|
|||
# Python Tools for Visual Studio (PTVS) |
|||
__pycache__/ |
|||
*.pyc |
|||
|
|||
# CMake build directory |
|||
build |
|||
|
|||
# Cppcheck build directory |
|||
analysis-cppcheck-build-dir |
|||
|
|||
# Ideas directory |
|||
ideas |
|||
|
|||
desktop.iniimages/ |
|||
@ -0,0 +1,39 @@ |
|||
matrix: |
|||
include: |
|||
- os: linux |
|||
dist: bionic |
|||
language: cpp |
|||
compiler: gcc |
|||
addons: |
|||
apt: |
|||
sources: |
|||
- ubuntu-toolchain-r-test |
|||
packages: |
|||
- g++-8 |
|||
env: CXX=g++-8 CC=gcc-8 |
|||
- os: osx |
|||
osx_image: xcode10.2 |
|||
language: cpp |
|||
compiler: clang |
|||
- os: windows |
|||
language: bash |
|||
env: CXX=cl.exe |
|||
install: |
|||
- | |
|||
if [[ $TRAVIS_OS_NAME == 'windows' ]]; then |
|||
choco install ninja cmake |
|||
elif [[ $TRAVIS_OS_NAME == 'osx' ]]; then |
|||
export PATH=~/Library/Python/3.7/bin:$PATH |
|||
pip3 install --user ninja cmake |
|||
else |
|||
pipenv global 3.6 |
|||
pip install --user ninja cmake |
|||
fi |
|||
script: |
|||
- | |
|||
if [[ $TRAVIS_OS_NAME == 'windows' ]]; then |
|||
tools/build.bat |
|||
else |
|||
sh tools/build.sh |
|||
fi |
|||
- ./build/test/tests |
|||
@ -0,0 +1,98 @@ |
|||
cmake_minimum_required(VERSION 3.12.4) |
|||
|
|||
project(argparse |
|||
VERSION 2.9.0 |
|||
DESCRIPTION "A single header argument parser for C++17" |
|||
HOMEPAGE_URL "https://github.com/p-ranav/argparse" |
|||
LANGUAGES CXX |
|||
) |
|||
|
|||
option(ARGPARSE_BUILD_TESTS OFF) |
|||
option(ARGPARSE_LONG_VERSION_ARG_ONLY OFF) |
|||
|
|||
include(GNUInstallDirs) |
|||
include(CMakePackageConfigHelpers) |
|||
string(REPLACE "/${CMAKE_LIBRARY_ARCHITECTURE}" "" CMAKE_INSTALL_LIBDIR_ARCHIND "${CMAKE_INSTALL_LIBDIR}") |
|||
|
|||
|
|||
add_library(argparse INTERFACE) |
|||
add_library(argparse::argparse ALIAS argparse) |
|||
|
|||
|
|||
if (ARGPARSE_LONG_VERSION_ARG_ONLY) |
|||
target_compile_definitions(argparse INTERFACE ARGPARSE_LONG_VERSION_ARG_ONLY=true) |
|||
endif () |
|||
|
|||
target_compile_features(argparse INTERFACE cxx_std_17) |
|||
target_include_directories(argparse INTERFACE |
|||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> |
|||
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>) |
|||
|
|||
if(ARGPARSE_BUILD_SAMPLES) |
|||
add_subdirectory(samples) |
|||
endif() |
|||
|
|||
if(ARGPARSE_BUILD_TESTS) |
|||
add_subdirectory(test) |
|||
endif() |
|||
|
|||
install(TARGETS argparse EXPORT argparseConfig) |
|||
install(EXPORT argparseConfig |
|||
NAMESPACE argparse:: |
|||
DESTINATION ${CMAKE_INSTALL_LIBDIR_ARCHIND}/cmake/${PROJECT_NAME}) |
|||
install(FILES ${CMAKE_CURRENT_LIST_DIR}/include/argparse/argparse.hpp |
|||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/argparse) |
|||
|
|||
|
|||
set(CONFIG_FILE_NAME_WITHOUT_EXT "${PROJECT_NAME}Config") |
|||
set(CMAKE_CONFIG_FILE_BASENAME "${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_FILE_NAME_WITHOUT_EXT}") |
|||
set(CMAKE_CONFIG_VERSION_FILE_NAME "${CMAKE_CONFIG_FILE_BASENAME}-version.cmake") |
|||
set(CMAKE_CONFIG_FILE_NAME "${CMAKE_CONFIG_FILE_BASENAME}.cmake") |
|||
|
|||
if(${CMAKE_VERSION} VERSION_GREATER "3.14") |
|||
set(OPTIONAL_ARCH_INDEPENDENT "ARCH_INDEPENDENT") |
|||
endif() |
|||
|
|||
write_basic_package_version_file("${CMAKE_CONFIG_VERSION_FILE_NAME}" |
|||
COMPATIBILITY ExactVersion |
|||
${OPTIONAL_ARCH_INDEPENDENT} |
|||
) |
|||
|
|||
export(EXPORT argparseConfig |
|||
NAMESPACE argparse::) |
|||
|
|||
install(FILES "${CMAKE_CONFIG_VERSION_FILE_NAME}" |
|||
DESTINATION "${CMAKE_INSTALL_LIBDIR_ARCHIND}/cmake/${PROJECT_NAME}") |
|||
|
|||
set(PackagingTemplatesDir "${CMAKE_CURRENT_SOURCE_DIR}/packaging") |
|||
|
|||
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}") |
|||
set(CPACK_PACKAGE_VENDOR "argparse (C++) developers") |
|||
set(CPACK_PACKAGE_DESCRIPTION "${PROJECT_DESCRIPTION}") |
|||
set(CPACK_DEBIAN_PACKAGE_NAME "${CPACK_PACKAGE_NAME}") |
|||
set(CPACK_RPM_PACKAGE_NAME "${CPACK_PACKAGE_NAME}") |
|||
set(CPACK_PACKAGE_HOMEPAGE_URL "${PROJECT_HOMEPAGE_URL}") |
|||
set(CPACK_PACKAGE_MAINTAINER "Pranav Srinivas Kumar") |
|||
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${CPACK_PACKAGE_MAINTAINER}") |
|||
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") |
|||
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md") |
|||
|
|||
set(CPACK_DEBIAN_PACKAGE_NAME "lib${PROJECT_NAME}-dev") |
|||
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6-dev") |
|||
set(CPACK_DEBIAN_PACKAGE_SUGGESTS "cmake, pkg-config, pkg-conf") |
|||
|
|||
set(CPACK_RPM_PACKAGE_NAME "lib${PROJECT_NAME}-devel") |
|||
set(CPACK_RPM_PACKAGE_SUGGESTS "${CPACK_DEBIAN_PACKAGE_SUGGESTS}") |
|||
|
|||
set(CPACK_DEB_COMPONENT_INSTALL ON) |
|||
set(CPACK_RPM_COMPONENT_INSTALL ON) |
|||
set(CPACK_NSIS_COMPONENT_INSTALL ON) |
|||
set(CPACK_DEBIAN_COMPRESSION_TYPE "xz") |
|||
|
|||
set(PKG_CONFIG_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc") |
|||
configure_file("${PackagingTemplatesDir}/pkgconfig.pc.in" "${PKG_CONFIG_FILE_NAME}" @ONLY) |
|||
install(FILES "${PKG_CONFIG_FILE_NAME}" |
|||
DESTINATION "${CMAKE_INSTALL_LIBDIR_ARCHIND}/pkgconfig" |
|||
) |
|||
|
|||
include(CPack) |
|||
@ -0,0 +1,17 @@ |
|||
# Contributing |
|||
Contributions are welcomed. Open a pull-request or an issue. |
|||
|
|||
## Code of conduct |
|||
This project adheres to the [Open Code of Conduct][code-of-conduct]. By participating, you are expected to honor this code. |
|||
|
|||
[code-of-conduct]: https://github.com/spotify/code-of-conduct/blob/master/code-of-conduct.md |
|||
|
|||
## Code Style |
|||
|
|||
This project prefers, but does not strictly enforce, a specific source code style. The style is described in `.clang-format` and `.clang-tidy`. |
|||
|
|||
To generate a clang-tidy report: |
|||
|
|||
```bash |
|||
clang-tidy --extra-arg=-std=c++17 --config-file=.clang-tidy include/argparse/argparse.hpp |
|||
``` |
|||
@ -0,0 +1,7 @@ |
|||
Copyright (c) 2018 Pranav Srinivas Kumar <pranav.srinivas.kumar@gmail.com> |
|||
|
|||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: |
|||
|
|||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|||
1143
thirdparty/argparse/README.md
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1 @@ |
|||
clang-format -i include/argparse/*.hpp test/*.cpp samples/*.cpp |
|||
@ -0,0 +1,10 @@ |
|||
from conans import ConanFile |
|||
|
|||
class ArgparseConan(ConanFile): |
|||
name = "argparse" |
|||
version = "2.9" |
|||
exports_sources = "include/argparse.hpp" |
|||
no_copy_source = True |
|||
|
|||
def package(self): |
|||
self.copy("argparse.hpp") |
|||
1652
thirdparty/argparse/include/argparse/argparse.hpp
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,7 @@ |
|||
prefix=@CMAKE_INSTALL_PREFIX@ |
|||
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ |
|||
|
|||
Name: @PROJECT_NAME@ |
|||
Description: @PROJECT_DESCRIPTION@ |
|||
Version: @PROJECT_VERSION@ |
|||
Cflags: -I${includedir} |
|||
@ -0,0 +1,46 @@ |
|||
cmake_minimum_required(VERSION 3.6) |
|||
project(argparse_samples) |
|||
|
|||
if(MSVC) |
|||
# Force to always compile with W4 |
|||
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") |
|||
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") |
|||
else() |
|||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") |
|||
endif() |
|||
elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) |
|||
# Update if necessary |
|||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -pedantic -Wsign-conversion -Wshadow -Wconversion") |
|||
endif() |
|||
|
|||
if(NOT CMAKE_BUILD_TYPE) |
|||
set(CMAKE_BUILD_TYPE Release) |
|||
endif() |
|||
|
|||
# Disable deprecation for windows |
|||
if (WIN32) |
|||
add_compile_definitions(_CRT_SECURE_NO_WARNINGS) |
|||
endif() |
|||
|
|||
function(add_sample NAME) |
|||
ADD_EXECUTABLE(ARGPARSE_SAMPLE_${NAME} ${NAME}.cpp) |
|||
INCLUDE_DIRECTORIES("../include" ".") |
|||
TARGET_LINK_LIBRARIES(ARGPARSE_SAMPLE_${NAME} PRIVATE argparse::argparse) |
|||
set_target_properties(ARGPARSE_SAMPLE_${NAME} PROPERTIES OUTPUT_NAME ${NAME}) |
|||
endfunction() |
|||
|
|||
add_sample(positional_argument) |
|||
add_sample(optional_flag_argument) |
|||
add_sample(required_optional_argument) |
|||
add_sample(is_used) |
|||
add_sample(joining_repeated_optional_arguments) |
|||
add_sample(repeating_argument_to_increase_value) |
|||
add_sample(negative_numbers) |
|||
add_sample(description_epilog_metavar) |
|||
add_sample(list_of_arguments) |
|||
add_sample(compound_arguments) |
|||
add_sample(gathering_remaining_arguments) |
|||
add_sample(subcommands) |
|||
add_sample(parse_known_args) |
|||
add_sample(custom_prefix_characters) |
|||
add_sample(custom_assignment_characters) |
|||
@ -0,0 +1,36 @@ |
|||
#include <argparse/argparse.hpp>
|
|||
|
|||
int main(int argc, char *argv[]) { |
|||
argparse::ArgumentParser program("test"); |
|||
|
|||
program.add_argument("-a").default_value(false).implicit_value(true); |
|||
|
|||
program.add_argument("-b").default_value(false).implicit_value(true); |
|||
|
|||
program.add_argument("-c") |
|||
.nargs(2) |
|||
.default_value(std::vector<float>{0.0f, 0.0f}) |
|||
.scan<'g', float>(); |
|||
|
|||
try { |
|||
program.parse_args(argc, argv); // Example: ./main -abc 1.95 2.47
|
|||
} catch (const std::runtime_error &err) { |
|||
std::cerr << err.what() << std::endl; |
|||
std::cerr << program; |
|||
std::exit(1); |
|||
} |
|||
|
|||
auto a = program.get<bool>("-a"); // true
|
|||
auto b = program.get<bool>("-b"); // true
|
|||
auto c = program.get<std::vector<float>>("-c"); // {1.95, 2.47}
|
|||
|
|||
std::cout << "a: " << std::boolalpha << a << "\n"; |
|||
std::cout << "b: " << b << "\n"; |
|||
if (!c.empty()) { |
|||
std::cout << "c: "; |
|||
for (auto &v : c) { |
|||
std::cout << v << " "; |
|||
} |
|||
std::cout << std::endl; |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
#include <argparse/argparse.hpp>
|
|||
#include <cassert>
|
|||
|
|||
int main(int argc, char *argv[]) { |
|||
argparse::ArgumentParser program("test"); |
|||
program.set_prefix_chars("-+/"); |
|||
program.set_assign_chars("=:"); |
|||
|
|||
program.add_argument("--foo"); |
|||
program.add_argument("/B"); |
|||
|
|||
try { |
|||
program.parse_args(argc, argv); |
|||
} catch (const std::runtime_error &err) { |
|||
std::cerr << err.what() << std::endl; |
|||
std::cerr << program; |
|||
std::exit(1); |
|||
} |
|||
|
|||
if (program.is_used("--foo")) { |
|||
std::cout << "--foo : " << program.get("--foo") << "\n"; |
|||
} |
|||
|
|||
if (program.is_used("/B")) { |
|||
std::cout << "/B : " << program.get("/B") << "\n"; |
|||
} |
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
#include <argparse/argparse.hpp>
|
|||
#include <cassert>
|
|||
|
|||
int main(int argc, char *argv[]) { |
|||
argparse::ArgumentParser program("test"); |
|||
program.set_prefix_chars("-+/"); |
|||
|
|||
program.add_argument("+f"); |
|||
program.add_argument("--bar"); |
|||
program.add_argument("/foo"); |
|||
|
|||
try { |
|||
program.parse_args(argc, argv); |
|||
} catch (const std::runtime_error &err) { |
|||
std::cerr << err.what() << std::endl; |
|||
std::cerr << program; |
|||
std::exit(1); |
|||
} |
|||
|
|||
if (program.is_used("+f")) { |
|||
std::cout << "+f : " << program.get("+f") << "\n"; |
|||
} |
|||
|
|||
if (program.is_used("--bar")) { |
|||
std::cout << "--bar : " << program.get("--bar") << "\n"; |
|||
} |
|||
|
|||
if (program.is_used("/foo")) { |
|||
std::cout << "/foo : " << program.get("/foo") << "\n"; |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
#include <argparse/argparse.hpp>
|
|||
|
|||
int main(int argc, char *argv[]) { |
|||
argparse::ArgumentParser program("main"); |
|||
program.add_argument("thing").help("Thing to use.").metavar("THING"); |
|||
program.add_argument("--member") |
|||
.help("The alias for the member to pass to.") |
|||
.metavar("ALIAS"); |
|||
program.add_argument("--verbose").default_value(false).implicit_value(true); |
|||
|
|||
program.add_description("Forward a thing to the next member."); |
|||
program.add_epilog("Possible things include betingalw, chiz, and res."); |
|||
|
|||
program.parse_args(argc, argv); |
|||
|
|||
std::cout << program << std::endl; |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
#include <argparse/argparse.hpp>
|
|||
|
|||
int main(int argc, char *argv[]) { |
|||
argparse::ArgumentParser program("compiler"); |
|||
|
|||
program.add_argument("files").remaining(); |
|||
|
|||
try { |
|||
program.parse_args(argc, argv); |
|||
} catch (const std::runtime_error &err) { |
|||
std::cerr << err.what() << std::endl; |
|||
std::cerr << program; |
|||
std::exit(1); |
|||
} |
|||
|
|||
try { |
|||
auto files = program.get<std::vector<std::string>>("files"); |
|||
std::cout << files.size() << " files provided" << std::endl; |
|||
for (auto &file : files) |
|||
std::cout << file << std::endl; |
|||
} catch (std::logic_error &e) { |
|||
std::cout << "No files provided" << std::endl; |
|||
} |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
#include <argparse/argparse.hpp>
|
|||
|
|||
int main(int argc, char *argv[]) { |
|||
argparse::ArgumentParser program("test"); |
|||
|
|||
program.add_argument("--color") |
|||
.default_value(std::string{ |
|||
"orange"}) // might otherwise be type const char* leading to an error
|
|||
// when trying program.get<std::string>
|
|||
.help("specify the cat's fur color"); |
|||
|
|||
try { |
|||
program.parse_args(argc, argv); // Example: ./main --color orange
|
|||
} catch (const std::runtime_error &err) { |
|||
std::cerr << err.what() << std::endl; |
|||
std::cerr << program; |
|||
std::exit(1); |
|||
} |
|||
|
|||
auto color = program.get<std::string>("--color"); // "orange"
|
|||
auto explicit_color = |
|||
program.is_used("--color"); // true, user provided orange
|
|||
std::cout << "Color: " << color << "\n"; |
|||
std::cout << "Argument was explicitly provided by user? " << std::boolalpha |
|||
<< explicit_color << "\n"; |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
#include <argparse/argparse.hpp>
|
|||
|
|||
int main(int argc, char *argv[]) { |
|||
argparse::ArgumentParser program("test"); |
|||
|
|||
program.add_argument("--color") |
|||
.default_value<std::vector<std::string>>({"orange"}) |
|||
.append() |
|||
.help("specify the cat's fur color"); |
|||
|
|||
try { |
|||
program.parse_args( |
|||
argc, argv); // Example: ./main --color red --color green --color blue
|
|||
} catch (const std::runtime_error &err) { |
|||
std::cerr << err.what() << std::endl; |
|||
std::cerr << program; |
|||
std::exit(1); |
|||
} |
|||
|
|||
auto colors = program.get<std::vector<std::string>>( |
|||
"--color"); // {"red", "green", "blue"}
|
|||
|
|||
std::cout << "Colors: "; |
|||
for (const auto &c : colors) { |
|||
std::cout << c << " "; |
|||
} |
|||
std::cout << "\n"; |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
#include <argparse/argparse.hpp>
|
|||
|
|||
int main(int argc, char *argv[]) { |
|||
|
|||
argparse::ArgumentParser program("main"); |
|||
|
|||
program.add_argument("--input_files") |
|||
.help("The list of input files") |
|||
.nargs(2); |
|||
|
|||
try { |
|||
program.parse_args( |
|||
argc, argv); // Example: ./main --input_files config.yml System.xml
|
|||
} catch (const std::runtime_error &err) { |
|||
std::cerr << err.what() << std::endl; |
|||
std::cerr << program; |
|||
std::exit(1); |
|||
} |
|||
|
|||
auto files = program.get<std::vector<std::string>>( |
|||
"--input_files"); // {"config.yml", "System.xml"}
|
|||
|
|||
if (!files.empty()) { |
|||
std::cout << "Files: "; |
|||
for (auto &file : files) { |
|||
std::cout << file << " "; |
|||
} |
|||
std::cout << std::endl; |
|||
} |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
#include <argparse/argparse.hpp>
|
|||
|
|||
int main(int argc, char *argv[]) { |
|||
argparse::ArgumentParser program("test"); |
|||
|
|||
program.add_argument("integer").help("Input number").scan<'i', int>(); |
|||
|
|||
program.add_argument("floats") |
|||
.help("Vector of floats") |
|||
.nargs(4) |
|||
.scan<'g', float>(); |
|||
|
|||
try { |
|||
program.parse_args(argc, argv); |
|||
} catch (const std::runtime_error &err) { |
|||
std::cerr << err.what() << std::endl; |
|||
std::cerr << program; |
|||
std::exit(1); |
|||
} |
|||
|
|||
if (program.is_used("integer")) { |
|||
std::cout << "Integer : " << program.get<int>("integer") << "\n"; |
|||
} |
|||
|
|||
if (program.is_used("floats")) { |
|||
std::cout << "Floats : "; |
|||
for (const auto &f : program.get<std::vector<float>>("floats")) { |
|||
std::cout << f << " "; |
|||
} |
|||
std::cout << std::endl; |
|||
} |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
#include <argparse/argparse.hpp>
|
|||
|
|||
int main(int argc, char *argv[]) { |
|||
argparse::ArgumentParser program("test"); |
|||
|
|||
program.add_argument("--verbose") |
|||
.help("increase output verbosity") |
|||
.default_value(false) |
|||
.implicit_value(true); |
|||
|
|||
try { |
|||
program.parse_args(argc, argv); |
|||
} catch (const std::runtime_error &err) { |
|||
std::cerr << err.what() << std::endl; |
|||
std::cerr << program; |
|||
std::exit(1); |
|||
} |
|||
|
|||
if (program["--verbose"] == true) { |
|||
std::cout << "Verbosity enabled" << std::endl; |
|||
} |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
#include <argparse/argparse.hpp>
|
|||
#include <cassert>
|
|||
|
|||
int main(int argc, char *argv[]) { |
|||
argparse::ArgumentParser program("test"); |
|||
program.add_argument("--foo").implicit_value(true).default_value(false); |
|||
program.add_argument("bar"); |
|||
|
|||
auto unknown_args = program.parse_known_args(argc, argv); |
|||
|
|||
if (program.is_used("--foo")) { |
|||
std::cout << "--foo : " << program.get<bool>("--foo") << "\n"; |
|||
} |
|||
|
|||
if (program.is_used("bar")) { |
|||
std::cout << "bar : " << program.get<std::string>("bar") << "\n"; |
|||
} |
|||
|
|||
if (!unknown_args.empty()) { |
|||
std::cout << "Unknown args : "; |
|||
for (const auto &u : unknown_args) { |
|||
std::cout << u << " "; |
|||
} |
|||
std::cout << std::endl; |
|||
} |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
#include <argparse/argparse.hpp>
|
|||
|
|||
int main(int argc, char *argv[]) { |
|||
argparse::ArgumentParser program("main"); |
|||
|
|||
program.add_argument("square") |
|||
.help("display the square of a given number") |
|||
.scan<'i', int>(); |
|||
|
|||
program.add_argument("--verbose").default_value(false).implicit_value(true); |
|||
|
|||
try { |
|||
program.parse_args(argc, argv); |
|||
} catch (const std::runtime_error &err) { |
|||
std::cerr << err.what() << std::endl; |
|||
std::cerr << program; |
|||
std::exit(1); |
|||
} |
|||
|
|||
int input = program.get<int>("square"); |
|||
|
|||
if (program["--verbose"] == true) { |
|||
std::cout << "The square of " << input << " is " << (input * input) |
|||
<< std::endl; |
|||
} else { |
|||
std::cout << (input * input) << std::endl; |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
#include <argparse/argparse.hpp>
|
|||
|
|||
int main(int argc, char *argv[]) { |
|||
argparse::ArgumentParser program("test"); |
|||
|
|||
int verbosity = 0; |
|||
program.add_argument("-V", "--verbose") |
|||
.action([&](const auto &) { ++verbosity; }) |
|||
.append() |
|||
.default_value(false) |
|||
.implicit_value(true) |
|||
.nargs(0); |
|||
|
|||
program.parse_args(argc, argv); // Example: ./main -VVVV
|
|||
|
|||
std::cout << "verbose level: " << verbosity << std::endl; // verbose level: 4
|
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
#include <argparse/argparse.hpp>
|
|||
|
|||
int main(int argc, char *argv[]) { |
|||
argparse::ArgumentParser program("test"); |
|||
|
|||
program.add_argument("-o", "--output") |
|||
.required() |
|||
.help("specify the output file."); |
|||
|
|||
try { |
|||
program.parse_args(argc, argv); |
|||
} catch (const std::runtime_error &err) { |
|||
std::cerr << err.what() << std::endl; |
|||
std::cerr << program; |
|||
std::exit(1); |
|||
} |
|||
|
|||
std::cout << "Output written to " << program.get("-o") << "\n"; |
|||
} |
|||
@ -0,0 +1,65 @@ |
|||
#include <argparse/argparse.hpp>
|
|||
|
|||
int main(int argc, char *argv[]) { |
|||
argparse::ArgumentParser program("git"); |
|||
|
|||
// git add subparser
|
|||
argparse::ArgumentParser add_command("add"); |
|||
add_command.add_description("Add file contents to the index"); |
|||
add_command.add_argument("files") |
|||
.help("Files to add content from. Fileglobs (e.g. *.c) can be given to " |
|||
"add all matching files.") |
|||
.remaining(); |
|||
|
|||
// git commit subparser
|
|||
argparse::ArgumentParser commit_command("commit"); |
|||
commit_command.add_description("Record changes to the repository"); |
|||
commit_command.add_argument("-a", "--all") |
|||
.help("Tell the command to automatically stage files that have been " |
|||
"modified and deleted.") |
|||
.default_value(false) |
|||
.implicit_value(true); |
|||
|
|||
commit_command.add_argument("-m", "--message") |
|||
.help("Use the given <msg> as the commit message."); |
|||
|
|||
// git cat-file subparser
|
|||
argparse::ArgumentParser catfile_command("cat-file"); |
|||
catfile_command.add_description( |
|||
"Provide content or type and size information for repository objects"); |
|||
catfile_command.add_argument("-t").help( |
|||
"Instead of the content, show the object type identified by <object>."); |
|||
|
|||
catfile_command.add_argument("-p").help( |
|||
"Pretty-print the contents of <object> based on its type."); |
|||
|
|||
// git submodule subparser
|
|||
argparse::ArgumentParser submodule_command("submodule"); |
|||
submodule_command.add_description("Initialize, update or inspect submodules"); |
|||
argparse::ArgumentParser submodule_update_command("update"); |
|||
submodule_update_command.add_description( |
|||
"Update the registered submodules to match what the superproject " |
|||
"expects"); |
|||
submodule_update_command.add_argument("--init") |
|||
.default_value(false) |
|||
.implicit_value(true); |
|||
submodule_update_command.add_argument("--recursive") |
|||
.default_value(false) |
|||
.implicit_value(true); |
|||
submodule_command.add_subparser(submodule_update_command); |
|||
|
|||
program.add_subparser(add_command); |
|||
program.add_subparser(commit_command); |
|||
program.add_subparser(catfile_command); |
|||
program.add_subparser(submodule_command); |
|||
|
|||
try { |
|||
program.parse_args(argc, argv); |
|||
} catch (const std::runtime_error &err) { |
|||
std::cerr << err.what() << std::endl; |
|||
std::cerr << program; |
|||
std::exit(1); |
|||
} |
|||
|
|||
// Use arguments
|
|||
} |
|||
@ -0,0 +1,2 @@ |
|||
build/ |
|||
build_linux/ |
|||
@ -0,0 +1,63 @@ |
|||
cmake_minimum_required(VERSION 3.6) |
|||
project(argparse_tests) |
|||
|
|||
if(MSVC) |
|||
# Force to always compile with W4 |
|||
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") |
|||
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") |
|||
else() |
|||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") |
|||
endif() |
|||
elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) |
|||
# Update if necessary |
|||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -pedantic -Wsign-conversion -Wshadow -Wconversion") |
|||
endif() |
|||
|
|||
if(NOT CMAKE_BUILD_TYPE) |
|||
set(CMAKE_BUILD_TYPE Release) |
|||
endif() |
|||
|
|||
# Disable deprecation for windows |
|||
if (WIN32) |
|||
add_compile_definitions(_CRT_SECURE_NO_WARNINGS) |
|||
endif() |
|||
|
|||
# ARGPARSE executable |
|||
file(GLOB ARGPARSE_TEST_SOURCES |
|||
main.cpp |
|||
test_actions.cpp |
|||
test_append.cpp |
|||
test_compound_arguments.cpp |
|||
test_container_arguments.cpp |
|||
test_const_correct.cpp |
|||
test_default_args.cpp |
|||
test_get.cpp |
|||
test_help.cpp |
|||
test_invalid_arguments.cpp |
|||
test_is_used.cpp |
|||
test_issue_37.cpp |
|||
test_negative_numbers.cpp |
|||
test_optional_arguments.cpp |
|||
test_parent_parsers.cpp |
|||
test_parse_args.cpp |
|||
test_positional_arguments.cpp |
|||
test_repr.cpp |
|||
test_required_arguments.cpp |
|||
test_scan.cpp |
|||
test_value_semantics.cpp |
|||
test_version.cpp |
|||
test_subparsers.cpp |
|||
test_parse_known_args.cpp |
|||
test_equals_form.cpp |
|||
test_prefix_chars.cpp |
|||
) |
|||
set_source_files_properties(main.cpp |
|||
PROPERTIES |
|||
COMPILE_DEFINITIONS DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN) |
|||
ADD_EXECUTABLE(ARGPARSE_TESTS ${ARGPARSE_TEST_SOURCES}) |
|||
INCLUDE_DIRECTORIES("../include" ".") |
|||
set_target_properties(ARGPARSE_TESTS PROPERTIES OUTPUT_NAME tests) |
|||
set_property(TARGET ARGPARSE_TESTS PROPERTY CXX_STANDARD 17) |
|||
|
|||
# Set ${PROJECT_NAME} as the startup project |
|||
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ARGPARSE_TESTS) |
|||
Some files were not shown because too many files changed in this diff
Write
Preview
Loading…
Cancel
Save
Reference in new issue