Skip to content

feat: Add command -cwd (change working directory) - #1024

Merged
hsutter merged 4 commits into
hsutter:mainfrom
helmesjo:feature-add-cwd-option
Jun 22, 2024
Merged

hsutter merged 4 commits into
hsutter:mainfrom
helmesjo:feature-add-cwd-option

Conversation

@helmesjo

@helmesjo helmesjo commented Mar 17, 2024 •

Copy link
Copy Markdown
Contributor

Makes it possible to have cppfront output generated files into a separate directory (unless -output is specified).

Before:

$ ls ..
../hello.cpp2
$ cppfront ../hello.cpp2
$ ls ..
../hello.cpp2
../hello.cpp

After (when using -cwd):

$ ls
./hello.cpp2
subdir/
$ cppfront -cwd ./subdir ./hello.cpp
$ tree
.
├── hello.cpp2
└── subdir
    └── hello.cpp

Side note:

Arguably the output path should always be the current working directory with option to retain relative sub-directory hierarchy, eg. when passing multiple files (this is how most tools operate), and not be derived from input files. Though I assumed that would break tests (and require more special handling/options).

So running cd build && cppfront [options] $(find . -name "*.h2" -o -name "*.cpp2") with this structure:

$ tree
├── one.cpp2
├── one.h2
└── subdir1
    ├── subdir2
    │   ├── three.cpp2
    │   └── three.h2
    ├── two.cpp2
    └── two.h2
$ mkdir build && cd build && cppfront [options] $(find . -name "*.h2" -o -name "*.cpp2")

could yield this result:

$ tree
├── build
│   ├── one.cpp
│   ├── one.h
│   └── subdir1
│       ├── subdir2
│       │   ├── three.cpp
│       │   └── three.h
│       ├── two.cpp
│       └── two.h
├── one.cpp2
├── one.h2
└── subdir1
    ├── subdir2
    │   ├── three.cpp2
    │   └── three.h2
    ├── two.cpp2
    └── two.h2

@helmesjo
helmesjo force-pushed the feature-add-cwd-option branch from e6500f4 to 0dfbc25 Compare March 17, 2024 23:12
@hsutter

hsutter commented Mar 20, 2024

Copy link
Copy Markdown
Owner

Thanks for your pull request! It looks like this may be your first contribution to cppfront. I've emailed you the Contributor License Agreement (CLA), and once it's signed I can look at your pull request. Thanks again for your contribution.

@helmesjo
helmesjo force-pushed the feature-add-cwd-option branch from 0dfbc25 to ab0f9ec Compare March 20, 2024 09:19
@helmesjo

Copy link
Copy Markdown
Contributor Author

Thanks for your pull request! It looks like this may be your first contribution to cppfront. I've emailed you the Contributor License Agreement (CLA), and once it's signed I can look at your pull request. Thanks again for your contribution.

Sure thing! Do you mind re-sending it though? My email got a bit mixed up so you sent it to the wrong one.