@@ -101,6 +101,15 @@ def generate(
101101 envvar = ["FIREFLY_CLIENT_SECRET" ],
102102 ),
103103 prompt : str = typer .Option (..., help = "Text prompt for image generation" ),
104+ num_variations : int = typer .Option (None , help = "Number of images to generate (numVariations)" ),
105+ style : str = typer .Option (None , help = "Style object as JSON string (presets, imageReference, strength, etc.)" ),
106+ structure : str = typer .Option (None , help = "Structure object as JSON string (strength, imageReference, etc.)" ),
107+ prompt_biasing_locale_code : str = typer .Option (None , help = "Locale code for prompt biasing (promptBiasingLocaleCode)" ),
108+ negative_prompt : str = typer .Option (None , help = "Negative prompt to avoid certain content" ),
109+ seed : int = typer .Option (None , help = "Seed for deterministic output" ),
110+ aspect_ratio : str = typer .Option (None , help = "Aspect ratio, e.g. '1:1', '16:9'" ),
111+ output_format : str = typer .Option (None , help = "Output format, e.g. 'jpeg', 'png'" ),
112+ content_class : str = typer .Option (None , help = "Content class: 'photo' or 'art'" ),
104113 download : bool = typer .Option (False , help = "Download the generated image to a file (filename is taken from the image URL)" ),
105114 show_images : bool = typer .Option (False , help = "Display the image in the terminal after download." ),
106115 use_mocks : bool = typer .Option (False , help = "Mock API responses for testing without a valid client secret." ),
@@ -114,11 +123,39 @@ def generate(
114123 raise typer .BadParameter ("client_id must be provided as an option or via the FIREFLY_CLIENT_ID environment variable." )
115124 if not client_secret :
116125 raise typer .BadParameter ("client_secret must be provided as an option or via the FIREFLY_CLIENT_SECRET environment variable." )
117- with with_maybe_use_mocks (use_mocks ):
118- _generate (client_id , client_secret , prompt , download , show_images , format , verbose )
119-
120-
121- def _generate (client_id , client_secret , prompt , download , show_images , format , verbose ):
126+ # Parse JSON for style/structure if provided
127+ style_obj = None
128+ if style :
129+ try :
130+ style_obj = json .loads (style )
131+ except Exception as e :
132+ raise typer .BadParameter (f"Invalid JSON for --style: { e } " )
133+ structure_obj = None
134+ if structure :
135+ try :
136+ structure_obj = json .loads (structure )
137+ except Exception as e :
138+ raise typer .BadParameter (f"Invalid JSON for --structure: { e } " )
139+ try :
140+ with with_maybe_use_mocks (use_mocks ):
141+ _generate (
142+ client_id , client_secret , prompt , download , show_images , format , verbose ,
143+ num_variations = num_variations ,
144+ style = style_obj ,
145+ structure = structure_obj ,
146+ prompt_biasing_locale_code = prompt_biasing_locale_code ,
147+ negative_prompt = negative_prompt ,
148+ seed = seed ,
149+ aspect_ratio = aspect_ratio ,
150+ output_format = output_format ,
151+ content_class = content_class ,
152+ )
153+ except ValueError as e :
154+ typer .secho (str (e ), fg = typer .colors .RED , err = True )
155+ raise typer .Exit (code = - 1 )
156+
157+
158+ def _generate (client_id , client_secret , prompt , download , show_images , format , verbose , ** kwargs ):
122159 client = FireflyClient (client_id = client_id , client_secret = client_secret )
123160 image_api_url = client .BASE_URL
124161 if verbose :
@@ -140,7 +177,7 @@ def capture_request(*args, **kwargs):
140177 _requests .request = capture_request
141178
142179 try :
143- response = client .generate_image (prompt = prompt )
180+ response = client .generate_image (prompt = prompt , ** kwargs )
144181 finally :
145182 _requests .request = orig_request
146183
0 commit comments