#now we just need the PHP version doco'd
1 messages ยท Page 1 of 1 (latest)
@gritty mango can you get this to work?
#[DaggerFunction]
#[Doc('Returns lines that match a pattern in the files of the provided Directory')]
public function grepDir(
#[DefaultPath('/')]
Directory $source,
): string {
I get
! required flag(s) "source" not set
if I don't specify it
or #[DefaultPath('.')]
either one
Ah...guessing I need
use Dagger\Attribute\DefaultPath;
Add Intelephense extension on vscode, for full autocompletion and auto-adding 'use' things at the top
yep, was just freehanding a bit. A language server is a must
I found this
->withDirectory("/app",
$this->source-
>withoutDirectory(".dagger")
)
but this is on a withDirectory or withMountedDirectory call
I'm trying to exclude it when the module loads up .. since it's got #[DefaultPath(".")] right at the start of the module
4am - sleep time - but i've got a bunch of badass code here for the PHP Blog, and for my community call tomorrow.
Wanting to optimise things a bit .. and show excluding of ./vendor/ on module load .. coz that's how things are currently done in PHP, using .dockerignore
here is my code btw ..
https://gist.github.com/dragoonis/d6588bb037ad18e782a4c11db0dd12e6
refresh gist - i added dagger.json
cya
<?php
declare(strict_types=1);
namespace DaggerModule;
use Dagger\Attribute\DaggerFunction;
use Dagger\Attribute\DaggerObject;
use Dagger\Attribute\DefaultPath;
use Dagger\Attribute\Ignore;
use Dagger\Attribute\Doc;
use Dagger\Directory;
use function Dagger\dag;
#[DaggerObject]
#[Doc('A generated module for ExIn functions')]
class ExIn
{
#[DaggerFunction]
#[Doc('Returns lines that match a pattern in the files of the provided Directory')]
public function grepDir(
#[Doc('Directory full of source code')]
#[DefaultPath('/')]
#[Ignore('vendor','one','two')]
Directory $source,
): string {
return dag()
->container()
->from('alpine:latest')
->withMountedDirectory('/mnt', $source)
->withWorkdir('/mnt')
->withExec(["grep", '-R', 'foo', '.'])
->stdout();
}
}
that works ๐ have files with a bunch of "foo" in them in dirs one and two and also filter vendor
@ember kraken great job - thank you! I'll use Ignore annotation - nicely done.
sharing knowledge of this Annotation with you @hidden blaze @faint nacelle
(Small bit of tidy up on the doc statement needed here -> https://gist.github.com/dragoonis/d6588bb037ad18e782a4c11db0dd12e6#file-laravelapp-php-L66)
What Annotation sorry?
EDIT: Oh Ignore, yes, Chris asked me to add at the same time as DefaultPath since they were both to do with context directories
That gist looks good. Nice simple start with a popular framework ๐