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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Konstantina Chremmou <Konstantina.Chremmou@cloud.com>
Signed-off-by: Konstantina Chremmou <Konstantina.Chremmou@cloud.com> # Conflicts: # ocaml/sdk-gen/powershell/gen_powershell_binding.ml
24cc4a7
to
4e8200b
Compare
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
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
`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 | ||
) | ||
) |
There was a problem hiding this comment.
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))]
First installment of PS templatization.