Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OIL] Templatization of PS Remove-Xen* cmdlets. Refactoring of HTTP_actions.mustache #5554

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kc284
Copy link
Contributor

@kc284 kc284 commented Apr 11, 2024

First installment of PS templatization.

Signed-off-by: Konstantina Chremmou <Konstantina.Chremmou@cloud.com>
@kc284 kc284 marked this pull request as draft April 11, 2024 10:08
Signed-off-by: Konstantina Chremmou <Konstantina.Chremmou@cloud.com>

# Conflicts:
#	ocaml/sdk-gen/powershell/gen_powershell_binding.ml
@kc284 kc284 force-pushed the private/konstantin1/sdk-ps branch from 24cc4a7 to 4e8200b Compare April 11, 2024 20:02
@kc284 kc284 marked this pull request as ready for review April 11, 2024 20:27
@duobei duobei self-requested a review April 18, 2024 08:27
Comment on lines 100 to +105
let cmdlets =
classes |> List.filter generated |> List.map gen_cmdlets |> List.concat
in
List.iter (fun x -> write_file x.filename x.content) cmdlets
List.iter (fun x -> write_file x.filename x.content) cmdlets ;

classes |> List.filter generated |> List.iter gen_destructor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let cmdlets =
classes |> List.filter generated |> List.map gen_cmdlets |> List.concat
in
List.iter (fun x -> write_file x.filename x.content) cmdlets
List.iter (fun x -> write_file x.filename x.content) cmdlets ;
classes |> List.filter generated |> List.iter gen_destructor
let classes_filterd = List.filter generated classes in
let cmdlets =
classes_filterd |> List.map gen_cmdlets |> List.concat
in
List.iter (fun x -> write_file x.filename x.content) cmdlets ;
List.iter gen_destructor classes_filterd

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

List.concat_map can be used to generate cmdlets as well

Comment on lines 168 to +197
`O
[
("licence", `String Licence.bsd_two_clause)
; ("http_actions", `A (List.map action_json filtered_actions))
( "http_actions"
, `A
(List.map
(fun (name, (meth, uri, _, sdkargs, _, _)) ->
`O
[
("name", `String name)
; ("isPut", `Bool (meth == Put))
; ("isGet", `Bool (meth == Get))
; ("uri", `String uri)
; ( "args"
, `A
(List.map
(fun x ->
`O
[
("arg_decl", `String (decl_of_sdkarg x))
; ("arg_use", `String (use_of_sdkarg x))
]
)
sdkargs
)
)
]
)
filtered_actions
)
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe below is little better:

let of_arg arg =
    `O
      [
        ("arg_decl", `String (decl_of_sdkarg arg))
      ; ("arg_use", `String (use_of_sdkarg arg))
      ]
  let of_action (name, (meth, uri, _, sdkargs, _, _)) =
    `O
      [
        ("name", `String name)
      ; ("isPut", `Bool (meth == Put))
      ; ("isGet", `Bool (meth == Get))
      ; ("uri", `String uri)
      ; ("args", `A (List.map of_arg sdkargs))
      ]
   in
  `O [( "http_actions", `A (List.map of_action filtered_actions))]

@kc284 kc284 self-assigned this Apr 25, 2024
@danilo-delbusso danilo-delbusso self-requested a review May 7, 2024 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants